Class: Vng::SystemObject

Inherits:
Resource show all
Defined in:
lib/vng/system_object.rb

Overview

Provides methods to interact with Vonigo system objects.

Constant Summary collapse

PATH =
'/api/v1/system/objects/'

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id:, name:, fields:) ⇒ SystemObject



10
11
12
13
14
# File 'lib/vng/system_object.rb', line 10

def initialize(id:, name:, fields:)
  @id = id
  @name = name
  @fields = fields
end

Instance Attribute Details

#fieldsObject (readonly)

Returns the value of attribute fields.



8
9
10
# File 'lib/vng/system_object.rb', line 8

def fields
  @fields
end

#idObject (readonly)

Returns the value of attribute id.



8
9
10
# File 'lib/vng/system_object.rb', line 8

def id
  @id
end

#nameObject (readonly)

Returns the value of attribute name.



8
9
10
# File 'lib/vng/system_object.rb', line 8

def name
  @name
end

Class Method Details

.find_by(name:) ⇒ Object



16
17
18
19
20
21
22
23
24
# File 'lib/vng/system_object.rb', line 16

def self.find_by(name:)
  data = request path: PATH
  object = data['Objects'].find{|object| object['name'].eql? name}

  if object
    fields = SystemField.for_system_object_id object['objectTypeID']
    new id: object['objectTypeID'], name: name, fields: fields
  end
end