Class: Ittybit::Automation

Inherits:
Object
  • Object
show all
Defined in:
lib/ittybit/types/automation.rb

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id:, trigger:, workflow:, status:, created:, updated:, name: OMIT, description: OMIT, additional_properties: nil) ⇒ Ittybit::Automation



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/ittybit/types/automation.rb', line 46

def initialize(id:, trigger:, workflow:, status:, created:, updated:, name: OMIT, description: OMIT,
               additional_properties: nil)
  @id = id
  @name = name if name != OMIT
  @description = description if description != OMIT
  @trigger = trigger
  @workflow = workflow
  @status = status
  @created = created
  @updated = updated
  @additional_properties = additional_properties
  @_field_set = {
    "id": id,
    "name": name,
    "description": description,
    "trigger": trigger,
    "workflow": workflow,
    "status": status,
    "created": created,
    "updated": updated
  }.reject do |_k, v|
    v == OMIT
  end
end

Instance Attribute Details

#additional_propertiesOpenStruct (readonly)



29
30
31
# File 'lib/ittybit/types/automation.rb', line 29

def additional_properties
  @additional_properties
end

#createdDateTime (readonly)



25
26
27
# File 'lib/ittybit/types/automation.rb', line 25

def created
  @created
end

#descriptionString (readonly)



17
18
19
# File 'lib/ittybit/types/automation.rb', line 17

def description
  @description
end

#idString (readonly)



13
14
15
# File 'lib/ittybit/types/automation.rb', line 13

def id
  @id
end

#nameString (readonly)



15
16
17
# File 'lib/ittybit/types/automation.rb', line 15

def name
  @name
end

#statusIttybit::AutomationStatus (readonly)



23
24
25
# File 'lib/ittybit/types/automation.rb', line 23

def status
  @status
end

#triggerIttybit::AutomationTrigger (readonly)



19
20
21
# File 'lib/ittybit/types/automation.rb', line 19

def trigger
  @trigger
end

#updatedDateTime (readonly)



27
28
29
# File 'lib/ittybit/types/automation.rb', line 27

def updated
  @updated
end

#workflowArray<Ittybit::AutomationWorkflowItem> (readonly)



21
22
23
# File 'lib/ittybit/types/automation.rb', line 21

def workflow
  @workflow
end

Class Method Details

.from_json(json_object:) ⇒ Ittybit::Automation

Deserialize a JSON object to an instance of Automation



75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# File 'lib/ittybit/types/automation.rb', line 75

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  id = parsed_json["id"]
  name = parsed_json["name"]
  description = parsed_json["description"]
  if parsed_json["trigger"].nil?
    trigger = nil
  else
    trigger = parsed_json["trigger"].to_json
    trigger = Ittybit::AutomationTrigger.from_json(json_object: trigger)
  end
  workflow = parsed_json["workflow"]&.map do |item|
    item = item.to_json
    Ittybit::AutomationWorkflowItem.from_json(json_object: item)
  end
  status = parsed_json["status"]
  created = (DateTime.parse(parsed_json["created"]) unless parsed_json["created"].nil?)
  updated = (DateTime.parse(parsed_json["updated"]) unless parsed_json["updated"].nil?)
  new(
    id: id,
    name: name,
    description: description,
    trigger: trigger,
    workflow: workflow,
    status: status,
    created: created,
    updated: updated,
    additional_properties: struct
  )
end

.validate_raw(obj:) ⇒ Void

Leveraged for Union-type generation, validate_raw attempts to parse the given

hash and check each fields type against the current object's property
definitions.


120
121
122
123
124
125
126
127
128
129
# File 'lib/ittybit/types/automation.rb', line 120

def self.validate_raw(obj:)
  obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.")
  obj.name&.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.")
  obj.description&.is_a?(String) != false || raise("Passed value for field obj.description is not the expected type, validation failed.")
  Ittybit::AutomationTrigger.validate_raw(obj: obj.trigger)
  obj.workflow.is_a?(Array) != false || raise("Passed value for field obj.workflow is not the expected type, validation failed.")
  obj.status.is_a?(Ittybit::AutomationStatus) != false || raise("Passed value for field obj.status is not the expected type, validation failed.")
  obj.created.is_a?(DateTime) != false || raise("Passed value for field obj.created is not the expected type, validation failed.")
  obj.updated.is_a?(DateTime) != false || raise("Passed value for field obj.updated is not the expected type, validation failed.")
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of Automation to a JSON object



110
111
112
# File 'lib/ittybit/types/automation.rb', line 110

def to_json(*_args)
  @_field_set&.to_json
end