Method: Folder.find

Defined in:
lib/models/folder.rb

.find(id) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/models/folder.rb', line 13

def find(id)
  json = JSON.parse(CryptopusAdapter.new.get("folders/#{id}"),
                    symbolize_names: true)
  included = json[:included] || []
  name = json[:data][:attributes][:name]
  encryptables = included.map do |record|
    Encryptable.from_json(record.to_json) if %w[encryptable_ose_secrets
                                            encryptable_credentials].include? record[:type]
  end.compact
  Folder.new(id: id, name: name, encryptables: encryptables)
end