Class: Yoti::DynamicSharingService::SourceConstraint

Inherits:
Object
  • Object
show all
Defined in:
lib/yoti/dynamic_share_service/policy/source_constraint.rb

Overview

A list of anchors to require for a dynamic share

Constant Summary collapse

DRIVING_LICENCE =
'DRIVING_LICENCE'
PASSPORT =
'PASSPORT'
NATIONAL_ID =
'NATIONAL_ID'
PASS_CARD =
'PASS_CARD'
SOURCE_CONSTRAINT =
'SOURCE'

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeSourceConstraint

Returns a new instance of SourceConstraint.



37
38
39
# File 'lib/yoti/dynamic_share_service/policy/source_constraint.rb', line 37

def initialize
  @anchors = []
end

Instance Attribute Details

#anchorsObject (readonly)

Returns the value of attribute anchors.



14
15
16
# File 'lib/yoti/dynamic_share_service/policy/source_constraint.rb', line 14

def anchors
  @anchors
end

Class Method Details

.builderObject



41
42
43
# File 'lib/yoti/dynamic_share_service/policy/source_constraint.rb', line 41

def self.builder
  SourceConstraintBuilder.new
end

Instance Method Details

#as_json(*_args) ⇒ Object



26
27
28
29
30
31
32
33
34
35
# File 'lib/yoti/dynamic_share_service/policy/source_constraint.rb', line 26

def as_json(*_args)
  obj = {
    type: SOURCE_CONSTRAINT,
    preferred_sources: {
      anchors: @anchors.map(&:as_json)
    }
  }
  obj[:preferred_sources][:soft_preference] = @soft_preference unless @soft_preference.nil?
  obj
end

#soft_preferenceObject



16
17
18
19
20
# File 'lib/yoti/dynamic_share_service/policy/source_constraint.rb', line 16

def soft_preference
  return @soft_preference if @soft_preference

  false
end

#to_json(*_args) ⇒ Object



22
23
24
# File 'lib/yoti/dynamic_share_service/policy/source_constraint.rb', line 22

def to_json(*_args)
  as_json.to_json
end