Class: Totvs::PasswordVault::Information
- Inherits:
-
Object
- Object
- Totvs::PasswordVault::Information
- Extended by:
- Forwardable
- Includes:
- JsonParser
- Defined in:
- lib/totvs/password_vault/information.rb
Instance Attribute Summary collapse
Instance Method Summary collapse
- #destroy(id:) ⇒ Object
-
#initialize(connection: nil) ⇒ Information
constructor
A new instance of Information.
-
#retrieve(id:) ⇒ Hash, Array
Content the saved content.
- #save(id:, content:, **kwargs) ⇒ Object
Methods included from JsonParser
Constructor Details
#initialize(connection: nil) ⇒ Information
Returns a new instance of Information.
16 17 18 |
# File 'lib/totvs/password_vault/information.rb', line 16 def initialize(connection: nil) @connection = connection end |
Instance Attribute Details
#connection ⇒ Object
20 21 22 |
# File 'lib/totvs/password_vault/information.rb', line 20 def connection @connection ||= Connection.new end |
Instance Method Details
#destroy(id:) ⇒ Object
52 53 54 55 |
# File 'lib/totvs/password_vault/information.rb', line 52 def destroy(id:) headers = { "Accept" => "application/json" } delete path: build_path(id), headers: headers end |
#retrieve(id:) ⇒ Hash, Array
Returns content the saved content.
27 28 29 30 31 32 33 |
# File 'lib/totvs/password_vault/information.rb', line 27 def retrieve(id:) headers = { "Accept" => "application/json" } response = get(path: build_path(id), headers: headers) response = parse_json(response.body) parse_json(response["info"]["conteudo"]) end |
#save(id:, content:, **kwargs) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/totvs/password_vault/information.rb', line 37 def save(id:, content:, **kwargs) headers = { "Accept" => "application/json", "Content-Type" => "application/json" } body = { conteudo: content.to_json }.merge(kwargs) post path: build_path(id), body: body, headers: headers end |