Class: Arcp::Credential

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id:, scheme:, value:, endpoint:, profile: nil, constraints: nil) ⇒ Credential

Returns a new instance of Credential.



5
6
7
8
9
10
11
12
13
14
# File 'lib/arcp/credential.rb', line 5

def initialize(id:, scheme:, value:, endpoint:, profile: nil, constraints: nil)
  super(
    id: id,
    scheme: scheme,
    value: value,
    endpoint: endpoint,
    profile: profile,
    constraints: constraints || {}
  )
end

Instance Attribute Details

#constraintsObject (readonly)

Returns the value of attribute constraints

Returns:

  • (Object)

    the current value of constraints



4
5
6
# File 'lib/arcp/credential.rb', line 4

def constraints
  @constraints
end

#endpointObject (readonly)

Returns the value of attribute endpoint

Returns:

  • (Object)

    the current value of endpoint



4
5
6
# File 'lib/arcp/credential.rb', line 4

def endpoint
  @endpoint
end

#idObject (readonly)

Returns the value of attribute id

Returns:

  • (Object)

    the current value of id



4
5
6
# File 'lib/arcp/credential.rb', line 4

def id
  @id
end

#profileObject (readonly)

Returns the value of attribute profile

Returns:

  • (Object)

    the current value of profile



4
5
6
# File 'lib/arcp/credential.rb', line 4

def profile
  @profile
end

#schemeObject (readonly)

Returns the value of attribute scheme

Returns:

  • (Object)

    the current value of scheme



4
5
6
# File 'lib/arcp/credential.rb', line 4

def scheme
  @scheme
end

#valueObject (readonly)

Returns the value of attribute value

Returns:

  • (Object)

    the current value of value



4
5
6
# File 'lib/arcp/credential.rb', line 4

def value
  @value
end

Class Method Details

.from_h(h) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/arcp/credential.rb', line 16

def self.from_h(h)
  h = h.transform_keys(&:to_s)
  new(
    id: h.fetch('id'),
    scheme: h.fetch('scheme'),
    value: h.fetch('value'),
    endpoint: h.fetch('endpoint'),
    profile: h['profile'],
    constraints: h['constraints'] || {}
  )
end

Instance Method Details

#to_hObject



28
29
30
31
32
33
# File 'lib/arcp/credential.rb', line 28

def to_h
  out = { 'id' => id, 'scheme' => scheme, 'value' => value, 'endpoint' => endpoint }
  out['profile'] = profile if profile
  out['constraints'] = constraints if constraints && !constraints.empty?
  out
end

#to_redacted_hObject



35
36
37
# File 'lib/arcp/credential.rb', line 35

def to_redacted_h
  to_h.merge('value' => '[REDACTED]')
end