Class: Vapi::Campaign

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

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(status:, name:, phone_number_id:, customers:, id:, org_id:, created_at:, updated_at:, calls:, calls_counter_scheduled:, calls_counter_queued:, calls_counter_in_progress:, calls_counter_ended_voicemail:, calls_counter_ended:, ended_reason: OMIT, assistant_id: OMIT, workflow_id: OMIT, schedule_plan: OMIT, additional_properties: nil) ⇒ Vapi::Campaign

Parameters:

  • status (Vapi::CampaignStatus)

    This is the status of the campaign.

  • ended_reason (Vapi::CampaignEndedReason) (defaults to: OMIT)

    This is the explanation for how the campaign ended.

  • name (String)

    This is the name of the campaign. This is just for your own reference.

  • assistant_id (String) (defaults to: OMIT)

    This is the assistant ID that will be used for the campaign calls. Note: Either assistantId or workflowId can be used, but not both.

  • workflow_id (String) (defaults to: OMIT)

    This is the workflow ID that will be used for the campaign calls. Note: Either assistantId or workflowId can be used, but not both.

  • phone_number_id (String)

    This is the phone number ID that will be used for the campaign calls.

  • schedule_plan (Vapi::SchedulePlan) (defaults to: OMIT)

    This is the schedule plan for the campaign.

  • customers (Array<Vapi::CreateCustomerDto>)

    These are the customers that will be called in the campaign.

  • id (String)

    This is the unique identifier for the campaign.

  • org_id (String)

    This is the unique identifier for the org that this campaign belongs to.

  • created_at (DateTime)

    This is the ISO 8601 date-time string of when the campaign was created.

  • updated_at (DateTime)

    This is the ISO 8601 date-time string of when the campaign was last updated.

  • calls (Hash{String => Object})

    This is a map of call IDs to campaign call details.

  • calls_counter_scheduled (Float)

    This is the number of calls that have been scheduled.

  • calls_counter_queued (Float)

    This is the number of calls that have been queued.

  • calls_counter_in_progress (Float)

    This is the number of calls that have been in progress.

  • calls_counter_ended_voicemail (Float)

    This is the number of calls whose ended reason is ‘voicemail’.

  • calls_counter_ended (Float)

    This is the number of calls that have ended.

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
# File 'lib/vapi_server_sdk/types/campaign.rb', line 81

def initialize(status:, name:, phone_number_id:, customers:, id:, org_id:, created_at:, updated_at:, calls:, calls_counter_scheduled:, calls_counter_queued:, calls_counter_in_progress:, calls_counter_ended_voicemail:, calls_counter_ended:, ended_reason: OMIT, assistant_id: OMIT, workflow_id: OMIT,
               schedule_plan: OMIT, additional_properties: nil)
  @status = status
  @ended_reason = ended_reason if ended_reason != OMIT
  @name = name
  @assistant_id = assistant_id if assistant_id != OMIT
  @workflow_id = workflow_id if workflow_id != OMIT
  @phone_number_id = phone_number_id
  @schedule_plan = schedule_plan if schedule_plan != OMIT
  @customers = customers
  @id = id
  @org_id = org_id
  @created_at = created_at
  @updated_at = updated_at
  @calls = calls
  @calls_counter_scheduled = calls_counter_scheduled
  @calls_counter_queued = calls_counter_queued
  @calls_counter_in_progress = calls_counter_in_progress
  @calls_counter_ended_voicemail = calls_counter_ended_voicemail
  @calls_counter_ended = calls_counter_ended
  @additional_properties = additional_properties
  @_field_set = {
    "status": status,
    "endedReason": ended_reason,
    "name": name,
    "assistantId": assistant_id,
    "workflowId": workflow_id,
    "phoneNumberId": phone_number_id,
    "schedulePlan": schedule_plan,
    "customers": customers,
    "id": id,
    "orgId": org_id,
    "createdAt": created_at,
    "updatedAt": updated_at,
    "calls": calls,
    "callsCounterScheduled": calls_counter_scheduled,
    "callsCounterQueued": calls_counter_queued,
    "callsCounterInProgress": calls_counter_in_progress,
    "callsCounterEndedVoicemail": calls_counter_ended_voicemail,
    "callsCounterEnded": calls_counter_ended
  }.reject do |_k, v|
    v == OMIT
  end
end

Instance Attribute Details

#additional_propertiesOpenStruct (readonly)

Returns Additional properties unmapped to the current class definition.

Returns:

  • (OpenStruct)

    Additional properties unmapped to the current class definition



52
53
54
# File 'lib/vapi_server_sdk/types/campaign.rb', line 52

def additional_properties
  @additional_properties
end

#assistant_idString (readonly)

Returns This is the assistant ID that will be used for the campaign calls. Note: Either assistantId or workflowId can be used, but not both.

Returns:

  • (String)

    This is the assistant ID that will be used for the campaign calls. Note: Either assistantId or workflowId can be used, but not both.



21
22
23
# File 'lib/vapi_server_sdk/types/campaign.rb', line 21

def assistant_id
  @assistant_id
end

#callsHash{String => Object} (readonly)

Returns This is a map of call IDs to campaign call details.

Returns:

  • (Hash{String => Object})

    This is a map of call IDs to campaign call details.



40
41
42
# File 'lib/vapi_server_sdk/types/campaign.rb', line 40

def calls
  @calls
end

#calls_counter_endedFloat (readonly)

Returns This is the number of calls that have ended.

Returns:

  • (Float)

    This is the number of calls that have ended.



50
51
52
# File 'lib/vapi_server_sdk/types/campaign.rb', line 50

def calls_counter_ended
  @calls_counter_ended
end

#calls_counter_ended_voicemailFloat (readonly)

Returns This is the number of calls whose ended reason is ‘voicemail’.

Returns:

  • (Float)

    This is the number of calls whose ended reason is ‘voicemail’.



48
49
50
# File 'lib/vapi_server_sdk/types/campaign.rb', line 48

def calls_counter_ended_voicemail
  @calls_counter_ended_voicemail
end

#calls_counter_in_progressFloat (readonly)

Returns This is the number of calls that have been in progress.

Returns:

  • (Float)

    This is the number of calls that have been in progress.



46
47
48
# File 'lib/vapi_server_sdk/types/campaign.rb', line 46

def calls_counter_in_progress
  @calls_counter_in_progress
end

#calls_counter_queuedFloat (readonly)

Returns This is the number of calls that have been queued.

Returns:

  • (Float)

    This is the number of calls that have been queued.



44
45
46
# File 'lib/vapi_server_sdk/types/campaign.rb', line 44

def calls_counter_queued
  @calls_counter_queued
end

#calls_counter_scheduledFloat (readonly)

Returns This is the number of calls that have been scheduled.

Returns:

  • (Float)

    This is the number of calls that have been scheduled.



42
43
44
# File 'lib/vapi_server_sdk/types/campaign.rb', line 42

def calls_counter_scheduled
  @calls_counter_scheduled
end

#created_atDateTime (readonly)

Returns This is the ISO 8601 date-time string of when the campaign was created.

Returns:

  • (DateTime)

    This is the ISO 8601 date-time string of when the campaign was created.



36
37
38
# File 'lib/vapi_server_sdk/types/campaign.rb', line 36

def created_at
  @created_at
end

#customersArray<Vapi::CreateCustomerDto> (readonly)

Returns These are the customers that will be called in the campaign.

Returns:



30
31
32
# File 'lib/vapi_server_sdk/types/campaign.rb', line 30

def customers
  @customers
end

#ended_reasonVapi::CampaignEndedReason (readonly)

Returns This is the explanation for how the campaign ended.

Returns:



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

def ended_reason
  @ended_reason
end

#idString (readonly)

Returns This is the unique identifier for the campaign.

Returns:

  • (String)

    This is the unique identifier for the campaign.



32
33
34
# File 'lib/vapi_server_sdk/types/campaign.rb', line 32

def id
  @id
end

#nameString (readonly)

Returns This is the name of the campaign. This is just for your own reference.

Returns:

  • (String)

    This is the name of the campaign. This is just for your own reference.



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

def name
  @name
end

#org_idString (readonly)

Returns This is the unique identifier for the org that this campaign belongs to.

Returns:

  • (String)

    This is the unique identifier for the org that this campaign belongs to.



34
35
36
# File 'lib/vapi_server_sdk/types/campaign.rb', line 34

def org_id
  @org_id
end

#phone_number_idString (readonly)

Returns This is the phone number ID that will be used for the campaign calls.

Returns:

  • (String)

    This is the phone number ID that will be used for the campaign calls.



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

def phone_number_id
  @phone_number_id
end

#schedule_planVapi::SchedulePlan (readonly)

Returns This is the schedule plan for the campaign.

Returns:



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

def schedule_plan
  @schedule_plan
end

#statusVapi::CampaignStatus (readonly)

Returns This is the status of the campaign.

Returns:



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

def status
  @status
end

#updated_atDateTime (readonly)

Returns This is the ISO 8601 date-time string of when the campaign was last updated.

Returns:

  • (DateTime)

    This is the ISO 8601 date-time string of when the campaign was last updated.



38
39
40
# File 'lib/vapi_server_sdk/types/campaign.rb', line 38

def updated_at
  @updated_at
end

#workflow_idString (readonly)

Returns This is the workflow ID that will be used for the campaign calls. Note: Either assistantId or workflowId can be used, but not both.

Returns:

  • (String)

    This is the workflow ID that will be used for the campaign calls. Note: Either assistantId or workflowId can be used, but not both.



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

def workflow_id
  @workflow_id
end

Class Method Details

.from_json(json_object:) ⇒ Vapi::Campaign

Deserialize a JSON object to an instance of Campaign

Parameters:

  • json_object (String)

Returns:



130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
# File 'lib/vapi_server_sdk/types/campaign.rb', line 130

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  status = parsed_json["status"]
  ended_reason = parsed_json["endedReason"]
  name = parsed_json["name"]
  assistant_id = parsed_json["assistantId"]
  workflow_id = parsed_json["workflowId"]
  phone_number_id = parsed_json["phoneNumberId"]
  if parsed_json["schedulePlan"].nil?
    schedule_plan = nil
  else
    schedule_plan = parsed_json["schedulePlan"].to_json
    schedule_plan = Vapi::SchedulePlan.from_json(json_object: schedule_plan)
  end
  customers = parsed_json["customers"]&.map do |item|
    item = item.to_json
    Vapi::CreateCustomerDto.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?)
  calls = parsed_json["calls"]
  calls_counter_scheduled = parsed_json["callsCounterScheduled"]
  calls_counter_queued = parsed_json["callsCounterQueued"]
  calls_counter_in_progress = parsed_json["callsCounterInProgress"]
  calls_counter_ended_voicemail = parsed_json["callsCounterEndedVoicemail"]
  calls_counter_ended = parsed_json["callsCounterEnded"]
  new(
    status: status,
    ended_reason: ended_reason,
    name: name,
    assistant_id: assistant_id,
    workflow_id: workflow_id,
    phone_number_id: phone_number_id,
    schedule_plan: schedule_plan,
    customers: customers,
    id: id,
    org_id: org_id,
    created_at: created_at,
    updated_at: updated_at,
    calls: calls,
    calls_counter_scheduled: calls_counter_scheduled,
    calls_counter_queued: calls_counter_queued,
    calls_counter_in_progress: calls_counter_in_progress,
    calls_counter_ended_voicemail: calls_counter_ended_voicemail,
    calls_counter_ended: calls_counter_ended,
    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)


195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
# File 'lib/vapi_server_sdk/types/campaign.rb', line 195

def self.validate_raw(obj:)
  obj.status.is_a?(Vapi::CampaignStatus) != false || raise("Passed value for field obj.status is not the expected type, validation failed.")
  obj.ended_reason&.is_a?(Vapi::CampaignEndedReason) != false || raise("Passed value for field obj.ended_reason 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.assistant_id&.is_a?(String) != false || raise("Passed value for field obj.assistant_id is not the expected type, validation failed.")
  obj.workflow_id&.is_a?(String) != false || raise("Passed value for field obj.workflow_id is not the expected type, validation failed.")
  obj.phone_number_id.is_a?(String) != false || raise("Passed value for field obj.phone_number_id is not the expected type, validation failed.")
  obj.schedule_plan.nil? || Vapi::SchedulePlan.validate_raw(obj: obj.schedule_plan)
  obj.customers.is_a?(Array) != false || raise("Passed value for field obj.customers 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.calls.is_a?(Hash) != false || raise("Passed value for field obj.calls is not the expected type, validation failed.")
  obj.calls_counter_scheduled.is_a?(Float) != false || raise("Passed value for field obj.calls_counter_scheduled is not the expected type, validation failed.")
  obj.calls_counter_queued.is_a?(Float) != false || raise("Passed value for field obj.calls_counter_queued is not the expected type, validation failed.")
  obj.calls_counter_in_progress.is_a?(Float) != false || raise("Passed value for field obj.calls_counter_in_progress is not the expected type, validation failed.")
  obj.calls_counter_ended_voicemail.is_a?(Float) != false || raise("Passed value for field obj.calls_counter_ended_voicemail is not the expected type, validation failed.")
  obj.calls_counter_ended.is_a?(Float) != false || raise("Passed value for field obj.calls_counter_ended is not the expected type, validation failed.")
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of Campaign to a JSON object

Returns:

  • (String)


185
186
187
# File 'lib/vapi_server_sdk/types/campaign.rb', line 185

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