Class: ComplyanceSDK::Models::Source
- Inherits:
-
Object
- Object
- ComplyanceSDK::Models::Source
- Defined in:
- lib/complyance_sdk/models/source.rb
Overview
Source model representing the origin of documents
Instance Attribute Summary collapse
-
#id ⇒ Object
Source ID.
-
#metadata ⇒ Object
Source metadata.
-
#name ⇒ Object
Source name.
-
#type ⇒ Object
Source type.
-
#version ⇒ Object
Source version.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Source
constructor
Initialize a new source.
-
#to_h ⇒ Hash
Convert the source to a hash.
-
#to_json(*args) ⇒ String
Convert the source to JSON.
-
#valid? ⇒ Boolean
Check if the source is valid.
Constructor Details
#initialize(options = {}) ⇒ Source
Initialize a new source
49 50 51 52 53 54 55 |
# File 'lib/complyance_sdk/models/source.rb', line 49 def initialize( = {}) @id = [:id] @type = parse_source_type([:type]) @name = [:name] @version = [:version] @metadata = [:metadata] || {} end |
Instance Attribute Details
#id ⇒ Object
Source ID
27 28 29 |
# File 'lib/complyance_sdk/models/source.rb', line 27 def id @id end |
#metadata ⇒ Object
Source metadata
39 40 41 |
# File 'lib/complyance_sdk/models/source.rb', line 39 def @metadata end |
#name ⇒ Object
Source name
33 34 35 |
# File 'lib/complyance_sdk/models/source.rb', line 33 def name @name end |
#type ⇒ Object
Source type
30 31 32 |
# File 'lib/complyance_sdk/models/source.rb', line 30 def type @type end |
#version ⇒ Object
Source version
36 37 38 |
# File 'lib/complyance_sdk/models/source.rb', line 36 def version @version end |
Instance Method Details
#to_h ⇒ Hash
Convert the source to a hash
60 61 62 63 64 65 66 67 68 |
# File 'lib/complyance_sdk/models/source.rb', line 60 def to_h { name: @name, version: @version, type: @type.to_s.upcase, identity: "#{@name}:#{@version}", id: "#{@name}:#{@version}" } end |
#to_json(*args) ⇒ String
Convert the source to JSON
73 74 75 |
# File 'lib/complyance_sdk/models/source.rb', line 73 def to_json(*args) to_h.to_json(*args) end |
#valid? ⇒ Boolean
Check if the source is valid
80 81 82 83 84 |
# File 'lib/complyance_sdk/models/source.rb', line 80 def valid? !@id.nil? && !@id.empty? && !@name.nil? && !@name.empty? && SourceType.all.include?(@type) end |