Class: Vapi::Workflow

Inherits:
Object
  • Object
show all
Defined in:
lib/vapi_server_sdk/types/workflow.rb

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type:, nodes:, id:, org_id:, created_at:, updated_at:, name:, edges:, additional_properties: nil) ⇒ Vapi::Workflow

Parameters:

  • type (String)
  • nodes (Array<Vapi::WorkflowNodesItem>)
  • id (String)
  • org_id (String)
  • created_at (DateTime)
  • updated_at (DateTime)
  • name (String)
  • edges (Array<Vapi::Edge>)
  • additional_properties (OpenStruct) (defaults to: nil) —

    Additional properties unmapped to the current class definition



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/vapi_server_sdk/types/workflow.rb', line 45

def initialize(type:, nodes:, id:, org_id:, created_at:, updated_at:, name:, edges:, additional_properties: nil)
  @type = type
  @nodes = nodes
  @id = id
  @org_id = org_id
  @created_at = created_at
  @updated_at = updated_at
  @name = name
  @edges = edges
  @additional_properties = additional_properties
  @_field_set = {
    "type": type,
    "nodes": nodes,
    "id": id,
    "orgId": org_id,
    "createdAt": created_at,
    "updatedAt": updated_at,
    "name": name,
    "edges": edges
  }
end

Instance Attribute Details

#additional_properties ⇒ OpenStruct (readonly)

Returns Additional properties unmapped to the current class definition.

Returns:

  • (OpenStruct) —

    Additional properties unmapped to the current class definition



28
29
30
# File 'lib/vapi_server_sdk/types/workflow.rb', line 28

def additional_properties
  @additional_properties
end

#created_at ⇒ DateTime (readonly)

Returns:

  • (DateTime)


20
21
22
# File 'lib/vapi_server_sdk/types/workflow.rb', line 20

def created_at
  @created_at
end

#edges ⇒ Array<Vapi::Edge> (readonly)

Returns:



26
27
28
# File 'lib/vapi_server_sdk/types/workflow.rb', line 26

def edges
  @edges
end

#id ⇒ String (readonly)

Returns:

  • (String)


16
17
18
# File 'lib/vapi_server_sdk/types/workflow.rb', line 16

def id
  @id
end

#name ⇒ String (readonly)

Returns:

  • (String)


24
25
26
# File 'lib/vapi_server_sdk/types/workflow.rb', line 24

def name
  @name
end

#nodes ⇒ Array<Vapi::WorkflowNodesItem> (readonly)

Returns:



14
15
16
# File 'lib/vapi_server_sdk/types/workflow.rb', line 14

def nodes
  @nodes
end

#org_id ⇒ String (readonly)

Returns:

  • (String)


18
19
20
# File 'lib/vapi_server_sdk/types/workflow.rb', line 18

def org_id
  @org_id
end

#type ⇒ String (readonly)

Returns:

  • (String)


12
13
14
# File 'lib/vapi_server_sdk/types/workflow.rb', line 12

def type
  @type
end

#updated_at ⇒ DateTime (readonly)

Returns:

  • (DateTime)


22
23
24
# File 'lib/vapi_server_sdk/types/workflow.rb', line 22

def updated_at
  @updated_at
end

Class Method Details

.from_json(json_object:) ⇒ Vapi::Workflow

Deserialize a JSON object to an instance of Workflow

Parameters:

  • json_object (String)

Returns:



71
72
73
74
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
# File 'lib/vapi_server_sdk/types/workflow.rb', line 71

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  type = parsed_json["type"]
  nodes = parsed_json["nodes"]&.map do |item|
    item = item.to_json
    Vapi::WorkflowNodesItem.from_json(json_object: item)
  end
  id = parsed_json["id"]
  org_id = parsed_json["orgId"]
  created_at = (DateTime.parse(parsed_json["createdAt"]) unless parsed_json["createdAt"].nil?)
  updated_at = (DateTime.parse(parsed_json["updatedAt"]) unless parsed_json["updatedAt"].nil?)
  name = parsed_json["name"]
  edges = parsed_json["edges"]&.map do |item|
    item = item.to_json
    Vapi::Edge.from_json(json_object: item)
  end
  new(
    type: type,
    nodes: nodes,
    id: id,
    org_id: org_id,
    created_at: created_at,
    updated_at: updated_at,
    name: name,
    edges: edges,
    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.

Parameters:

  • obj (Object)

Returns:

  • (Void)


114
115
116
117
118
119
120
121
122
123
# File 'lib/vapi_server_sdk/types/workflow.rb', line 114

def self.validate_raw(obj:)
  obj.type.is_a?(String) != false || raise("Passed value for field obj.type is not the expected type, validation failed.")
  obj.nodes.is_a?(Array) != false || raise("Passed value for field obj.nodes is not the expected type, validation failed.")
  obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.")
  obj.org_id.is_a?(String) != false || raise("Passed value for field obj.org_id is not the expected type, validation failed.")
  obj.created_at.is_a?(DateTime) != false || raise("Passed value for field obj.created_at is not the expected type, validation failed.")
  obj.updated_at.is_a?(DateTime) != false || raise("Passed value for field obj.updated_at 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.edges.is_a?(Array) != false || raise("Passed value for field obj.edges is not the expected type, validation failed.")
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of Workflow to a JSON object

Returns:

  • (String)


104
105
106
# File 'lib/vapi_server_sdk/types/workflow.rb', line 104

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