Class: Yoti::Sandbox::Profile::Anchor

Inherits:
Object
  • Object
show all
Defined in:
lib/yoti_sandbox/profile/anchor.rb

Overview

Represents an anchor that can be used by the profile sandbox service

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type:, value:, sub_type: '', timestamp: Time.now) ⇒ Anchor

Returns a new instance of Anchor.

Parameters:

  • type (String)
  • value (String)
  • sub_type (String) (defaults to: '')
  • timestamp (DateTime|Time) (defaults to: Time.now)


16
17
18
19
20
21
# File 'lib/yoti_sandbox/profile/anchor.rb', line 16

def initialize(type:, value:, sub_type: '', timestamp: Time.now)
  @type = type
  @value = value
  @sub_type = sub_type
  @timestamp = timestamp
end

Class Method Details

.source(value, sub_type: '', timestamp: Time.now) ⇒ Object

Parameters:

  • value (String)
  • sub_type (String) (defaults to: '')
  • timestamp (DateTime|Time) (defaults to: Time.now)


47
48
49
50
51
52
53
54
# File 'lib/yoti_sandbox/profile/anchor.rb', line 47

def self.source(value, sub_type: '', timestamp: Time.now)
  Anchor.new(
    type: 'SOURCE',
    value: value,
    sub_type: sub_type,
    timestamp: timestamp
  )
end

.verifier(value, sub_type: '', timestamp: Time.now) ⇒ Object

Parameters:

  • value (String)
  • sub_type (String) (defaults to: '')
  • timestamp (DateTime|Time) (defaults to: Time.now)


61
62
63
64
65
66
67
68
# File 'lib/yoti_sandbox/profile/anchor.rb', line 61

def self.verifier(value, sub_type: '', timestamp: Time.now)
  Anchor.new(
    type: 'VERIFIER',
    value: value,
    sub_type: sub_type,
    timestamp: timestamp
  )
end

Instance Method Details

#as_json(*_args) ⇒ Hash

Returns:

  • (Hash)


26
27
28
29
30
31
32
33
# File 'lib/yoti_sandbox/profile/anchor.rb', line 26

def as_json(*_args)
  {
    type: @type,
    value: @value,
    sub_type: @sub_type,
    timestamp: @timestamp.strftime('%s').to_i * 1_000_000
  }
end

#to_json(*args) ⇒ String

Returns:

  • (String)


38
39
40
# File 'lib/yoti_sandbox/profile/anchor.rb', line 38

def to_json(*args)
  as_json.to_json(*args)
end