Class: Brivo::Credential

Inherits:
Object
  • Object
show all
Defined in:
lib/brivo/credential.rb

Class Attribute Summary collapse

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Credential

Returns a new instance of Credential.



15
16
17
18
19
20
21
22
23
# File 'lib/brivo/credential.rb', line 15

def initialize attributes = {}
  @id = attributes['id']
  @reference_id = attributes['referenceId']
  @field_values = attributes['fieldValues']&.map do |field_value|
    field_value.inject({}) do |m, (k, v)|
      m.tap { m[k.to_sym] = v }
    end
  end
end

Class Attribute Details

.applicationObject

Returns the value of attribute application.



8
9
10
# File 'lib/brivo/credential.rb', line 8

def application
  @application
end

Instance Attribute Details

#field_valuesObject (readonly)

Returns the value of attribute field_values.



5
6
7
# File 'lib/brivo/credential.rb', line 5

def field_values
  @field_values
end

#idObject (readonly)

Returns the value of attribute id.



5
6
7
# File 'lib/brivo/credential.rb', line 5

def id
  @id
end

#reference_idObject (readonly)

Returns the value of attribute reference_id.



5
6
7
# File 'lib/brivo/credential.rb', line 5

def reference_id
  @reference_id
end

Class Method Details

.create(id:, facility_code:) ⇒ Object



10
11
12
# File 'lib/brivo/credential.rb', line 10

def create id:, facility_code:
  application.create_credential(id, facility_code)
end

Instance Method Details

#deleteObject



25
26
27
# File 'lib/brivo/credential.rb', line 25

def delete
  application.delete_credential(id)
end

#userObject



29
30
31
# File 'lib/brivo/credential.rb', line 29

def user
  application.credential_user(id)
end