totvs_password_vault 0.2.1 → 0.2.2

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
  SHA1:
3
- metadata.gz: 53fcfd1f1bae12cf2716894ba6475890e9fb8e21
4
- data.tar.gz: 87301a594713f746f3a6cd1d59768dad7029ae7e
3
+ metadata.gz: 0f6f892d39900fb0879459c62965ad8538758131
4
+ data.tar.gz: 34d040991a7c38fb0cffbb888a7fee4e83c51065
5
5
  SHA512:
6
- metadata.gz: c32d2a03cf6f5af2fbdad970fc2abdb9a3dcd0de991000046127db188e050d722314e18a5eb87a9af5c39e3ec62554fffe009f00190b9745b8a896992fa1a3d8
7
- data.tar.gz: 7a242e3d43e840f5be75def070f13b54eeadb93d19ce4ee3c9ae1fcadced96ad2a0148a484b17981bd5e7b777bd585567eb47162d8184ab6239e78af7b69396d
6
+ metadata.gz: 15b65d4c58143d252044392d973f789c5879efeb6f3b6dbf3c35c43540f2638c7305d12f47a24c0cab0aefd1b7ffb733033068eecea96c0b69e2afe403659bcf
7
+ data.tar.gz: d3187e8d6ec97ea9e6100ae487320c4b6e5cef371a0ae281fb76093d7f4fd7dcab9d29c7cd953f9c17c29ba470a88f76144e3c038581b6a02969200f125a3e04
@@ -5,6 +5,9 @@ module Totvs
5
5
  class Connection
6
6
  class Error < StandardError; end
7
7
  class TimeoutError < Error; end
8
+ class RegistryNotFoundError < Error; end
9
+ class InactiveRegistryError < Error; end
10
+
8
11
  class RequestFailure < Error
9
12
  attr_reader :response
10
13
 
@@ -154,12 +157,16 @@ module Totvs
154
157
  protected
155
158
 
156
159
  def validate_success!(response)
157
- unless response.is_a? Net::HTTPSuccess
160
+ if response.is_a? Net::HTTPNotFound
161
+ fail RegistryNotFoundError
162
+ elsif response.is_a? Net::HTTPGone
163
+ fail InactiveRegistryError, "This registry is inactive and can't be updated"
164
+ elsif response.is_a? Net::HTTPSuccess
165
+ return response
166
+ else
158
167
  message = "Response class: #{response}"
159
168
  fail RequestFailure.new message, response: response
160
169
  end
161
-
162
- response
163
170
  end
164
171
  end
165
172
  end
@@ -1,4 +1,5 @@
1
1
  require "forwardable"
2
+ require "time"
2
3
  require "totvs/password_vault/parsers/json_parser"
3
4
 
4
5
  module Totvs
@@ -51,6 +52,7 @@ module Totvs
51
52
  device_model: response["chave"]["modelo"],
52
53
  site: response["chave"]["site"],
53
54
  password_type: response["chave"]["tipo_senha"],
55
+ expiration_time: response["chave"]["datahora_expiracao"],
54
56
  tags: response["chave"]["tags"]
55
57
  }
56
58
  end
@@ -65,6 +67,7 @@ module Totvs
65
67
  # @param device_model [String, nil]
66
68
  # @param site [String, nil]
67
69
  # @param password_type [String, nil]
70
+ # @param expiration_time [Time, nil]
68
71
  # @param tags [Array[String], nil]
69
72
  def save(
70
73
  id:,
@@ -78,6 +81,7 @@ module Totvs
78
81
  device_model: nil,
79
82
  site: nil,
80
83
  password_type: nil,
84
+ expiration_time: nil,
81
85
  tags: [],
82
86
  **kwargs
83
87
  )
@@ -97,7 +101,8 @@ module Totvs
97
101
  modelo: device_model,
98
102
  site: site,
99
103
  tipo_senha: password_type,
100
- tags: tags.compact
104
+ datahora_expiracao: expiration_time ? expiration_time.iso8601 : nil,
105
+ tags: tags.compact.join(", ")
101
106
  }.merge(kwargs).delete_if { |_, value| value.nil? || value.empty? }
102
107
 
103
108
  post path: build_path(id), body: body, headers: headers
@@ -1,5 +1,5 @@
1
1
  module Totvs
2
2
  module PasswordVault
3
- VERSION = "0.2.1"
3
+ VERSION = "0.2.2"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: totvs_password_vault
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Guilherme da Silva Mello
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-09-22 00:00:00.000000000 Z
11
+ date: 2015-09-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: oauth