Class: Eso::IntegrationOption

Inherits:
Object
  • Object
show all
Defined in:
lib/eso/integration_option.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id: nil, name:, steps: []) ⇒ IntegrationOption

Returns a new instance of IntegrationOption.



26
27
28
29
30
# File 'lib/eso/integration_option.rb', line 26

def initialize(id: nil, name:, steps: [])
  @id = id
  @name = name
  @steps = steps
end

Instance Attribute Details

#idObject

Returns the value of attribute id.



24
25
26
# File 'lib/eso/integration_option.rb', line 24

def id
  @id
end

#nameObject

Returns the value of attribute name.



22
23
24
# File 'lib/eso/integration_option.rb', line 22

def name
  @name
end

#stepsObject

Returns the value of attribute steps.



23
24
25
# File 'lib/eso/integration_option.rb', line 23

def steps
  @steps
end

Class Method Details

.load(raw_integration_option) ⇒ IntegrationOption

Load a Hash of an IntegrationOption into an actual IntegrationOption. Probably didn’t need to break out separately, but might be useful

Parameters:

  • raw_integration_option (Hash)

    is a Hash representation of an IntegrationOption

Returns:



74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/eso/integration_option.rb', line 74

def self.load(raw_integration_option)
  integration_option = IntegrationOption.new(id: raw_integration_option[:id], name: raw_integration_option[:name])
  steps = raw_integration_option[:steps]
  steps.each do |step|
    step_config = step[:stepConfiguration]
    integration_option.steps << Step.new(uuid: step[:uuid],
                                         service_name: step[:serviceName],
                                         type_name: step_config[:typeName],
                                         previous_type_name: step_config[:previousTypeName],
                                         configuration_params: step_config[:configurationParams])
  end
  integration_option
end

Instance Method Details

#site_idObject



37
38
39
40
# File 'lib/eso/integration_option.rb', line 37

def site_id
  # As of now, the site is always in the last Step of the IntegrationOption. Might change.
  @steps.last.site_id
end

#site_id=(site_id) ⇒ Object



32
33
34
35
# File 'lib/eso/integration_option.rb', line 32

def site_id=(site_id)
  # As of now, the site is always in the last Step of the IntegrationOption. Might change.
  @steps.last.add_property(StepConfiguration::ConfigParamProperties::SITE_ID, site_id)
end

#to_hashHash

Return this object as a Hash. The corresponding Steps will still be objects.

Returns:

  • (Hash)

    Hash interpretation of this IntegrationOption.



63
64
65
66
67
# File 'lib/eso/integration_option.rb', line 63

def to_hash
  hash = {}
  instance_variables.each {|var| hash[var.to_s.delete("@")] = instance_variable_get(var)}
  hash
end

#to_jsonString

Return this object and the associated steps in a digestible JSON format.

Returns:

  • (String)

    JSON interpretation of this workflow.



46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/eso/integration_option.rb', line 46

def to_json
  # Convert Object to Hash
  hash = self.to_hash

  # Grab the Step objects and convert to Hashes
  steps = hash['steps']
  hashified_steps = []
  steps.each {|step| hashified_steps << step.to_hash}
  hash['steps'] = hashified_steps

  # Convert Hash to JSON
  hash.to_json
end