Class: Merge::Crm::Lead

Inherits:
Object
  • Object
show all
Defined in:
lib/merge_ruby_client/crm/types/lead.rb

Overview

The Lead Object

Description

The Lead object is used to represent an individual who is a potential customer.

Usage Example

TODO

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id: OMIT, remote_id: OMIT, created_at: OMIT, modified_at: OMIT, owner: OMIT, lead_source: OMIT, title: OMIT, company: OMIT, first_name: OMIT, last_name: OMIT, addresses: OMIT, email_addresses: OMIT, phone_numbers: OMIT, remote_updated_at: OMIT, remote_created_at: OMIT, converted_date: OMIT, converted_contact: OMIT, converted_account: OMIT, remote_was_deleted: OMIT, field_mappings: OMIT, remote_data: OMIT, remote_fields: OMIT, additional_properties: nil) ⇒ Merge::Crm::Lead



106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
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
# File 'lib/merge_ruby_client/crm/types/lead.rb', line 106

def initialize(id: OMIT, remote_id: OMIT, created_at: OMIT, modified_at: OMIT, owner: OMIT, lead_source: OMIT,
               title: OMIT, company: OMIT, first_name: OMIT, last_name: OMIT, addresses: OMIT, email_addresses: OMIT, phone_numbers: OMIT, remote_updated_at: OMIT, remote_created_at: OMIT, converted_date: OMIT, converted_contact: OMIT, converted_account: OMIT, remote_was_deleted: OMIT, field_mappings: OMIT, remote_data: OMIT, remote_fields: OMIT, additional_properties: nil)
  @id = id if id != OMIT
  @remote_id = remote_id if remote_id != OMIT
  @created_at = created_at if created_at != OMIT
  @modified_at = modified_at if modified_at != OMIT
  @owner = owner if owner != OMIT
  @lead_source = lead_source if lead_source != OMIT
  @title = title if title != OMIT
  @company = company if company != OMIT
  @first_name = first_name if first_name != OMIT
  @last_name = last_name if last_name != OMIT
  @addresses = addresses if addresses != OMIT
  @email_addresses = email_addresses if email_addresses != OMIT
  @phone_numbers = phone_numbers if phone_numbers != OMIT
  @remote_updated_at = remote_updated_at if remote_updated_at != OMIT
  @remote_created_at = remote_created_at if remote_created_at != OMIT
  @converted_date = converted_date if converted_date != OMIT
  @converted_contact = converted_contact if converted_contact != OMIT
   =  if  != OMIT
  @remote_was_deleted = remote_was_deleted if remote_was_deleted != OMIT
  @field_mappings = field_mappings if field_mappings != OMIT
  @remote_data = remote_data if remote_data != OMIT
  @remote_fields = remote_fields if remote_fields != OMIT
  @additional_properties = additional_properties
  @_field_set = {
    "id": id,
    "remote_id": remote_id,
    "created_at": created_at,
    "modified_at": modified_at,
    "owner": owner,
    "lead_source": lead_source,
    "title": title,
    "company": company,
    "first_name": first_name,
    "last_name": last_name,
    "addresses": addresses,
    "email_addresses": email_addresses,
    "phone_numbers": phone_numbers,
    "remote_updated_at": remote_updated_at,
    "remote_created_at": remote_created_at,
    "converted_date": converted_date,
    "converted_contact": converted_contact,
    "converted_account": ,
    "remote_was_deleted": remote_was_deleted,
    "field_mappings": field_mappings,
    "remote_data": remote_data,
    "remote_fields": remote_fields
  }.reject do |_k, v|
    v == OMIT
  end
end

Instance Attribute Details

#additional_propertiesOpenStruct (readonly)



72
73
74
# File 'lib/merge_ruby_client/crm/types/lead.rb', line 72

def additional_properties
  @additional_properties
end

#addressesArray<Merge::Crm::Address> (readonly)



45
46
47
# File 'lib/merge_ruby_client/crm/types/lead.rb', line 45

def addresses
  @addresses
end

#companyString (readonly)



39
40
41
# File 'lib/merge_ruby_client/crm/types/lead.rb', line 39

def company
  @company
end

#converted_accountMerge::Crm::LeadConvertedAccount (readonly)



59
60
61
# File 'lib/merge_ruby_client/crm/types/lead.rb', line 59

def 
  
end

#converted_contactMerge::Crm::LeadConvertedContact (readonly)



57
58
59
# File 'lib/merge_ruby_client/crm/types/lead.rb', line 57

def converted_contact
  @converted_contact
end

#converted_dateDateTime (readonly)



55
56
57
# File 'lib/merge_ruby_client/crm/types/lead.rb', line 55

def converted_date
  @converted_date
end

#created_atDateTime (readonly)



29
30
31
# File 'lib/merge_ruby_client/crm/types/lead.rb', line 29

def created_at
  @created_at
end

#email_addressesArray<Merge::Crm::EmailAddress> (readonly)



47
48
49
# File 'lib/merge_ruby_client/crm/types/lead.rb', line 47

def email_addresses
  @email_addresses
end

#field_mappingsHash{String => Object} (readonly)



66
67
68
# File 'lib/merge_ruby_client/crm/types/lead.rb', line 66

def field_mappings
  @field_mappings
end

#first_nameString (readonly)



41
42
43
# File 'lib/merge_ruby_client/crm/types/lead.rb', line 41

def first_name
  @first_name
end

#idString (readonly)



25
26
27
# File 'lib/merge_ruby_client/crm/types/lead.rb', line 25

def id
  @id
end

#last_nameString (readonly)



43
44
45
# File 'lib/merge_ruby_client/crm/types/lead.rb', line 43

def last_name
  @last_name
end

#lead_sourceString (readonly)



35
36
37
# File 'lib/merge_ruby_client/crm/types/lead.rb', line 35

def lead_source
  @lead_source
end

#modified_atDateTime (readonly)



31
32
33
# File 'lib/merge_ruby_client/crm/types/lead.rb', line 31

def modified_at
  @modified_at
end

#ownerMerge::Crm::LeadOwner (readonly)



33
34
35
# File 'lib/merge_ruby_client/crm/types/lead.rb', line 33

def owner
  @owner
end

#phone_numbersArray<Merge::Crm::PhoneNumber> (readonly)



49
50
51
# File 'lib/merge_ruby_client/crm/types/lead.rb', line 49

def phone_numbers
  @phone_numbers
end

#remote_created_atDateTime (readonly)



53
54
55
# File 'lib/merge_ruby_client/crm/types/lead.rb', line 53

def remote_created_at
  @remote_created_at
end

#remote_dataArray<Merge::Crm::RemoteData> (readonly)



68
69
70
# File 'lib/merge_ruby_client/crm/types/lead.rb', line 68

def remote_data
  @remote_data
end

#remote_fieldsArray<Merge::Crm::RemoteField> (readonly)



70
71
72
# File 'lib/merge_ruby_client/crm/types/lead.rb', line 70

def remote_fields
  @remote_fields
end

#remote_idString (readonly)



27
28
29
# File 'lib/merge_ruby_client/crm/types/lead.rb', line 27

def remote_id
  @remote_id
end

#remote_updated_atDateTime (readonly)



51
52
53
# File 'lib/merge_ruby_client/crm/types/lead.rb', line 51

def remote_updated_at
  @remote_updated_at
end

#remote_was_deletedBoolean (readonly)



64
65
66
# File 'lib/merge_ruby_client/crm/types/lead.rb', line 64

def remote_was_deleted
  @remote_was_deleted
end

#titleString (readonly)



37
38
39
# File 'lib/merge_ruby_client/crm/types/lead.rb', line 37

def title
  @title
end

Class Method Details

.from_json(json_object:) ⇒ Merge::Crm::Lead

Deserialize a JSON object to an instance of Lead



163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
# File 'lib/merge_ruby_client/crm/types/lead.rb', line 163

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  id = parsed_json["id"]
  remote_id = parsed_json["remote_id"]
  created_at = (DateTime.parse(parsed_json["created_at"]) unless parsed_json["created_at"].nil?)
  modified_at = (DateTime.parse(parsed_json["modified_at"]) unless parsed_json["modified_at"].nil?)
  if parsed_json["owner"].nil?
    owner = nil
  else
    owner = parsed_json["owner"].to_json
    owner = Merge::Crm::LeadOwner.from_json(json_object: owner)
  end
  lead_source = parsed_json["lead_source"]
  title = parsed_json["title"]
  company = parsed_json["company"]
  first_name = parsed_json["first_name"]
  last_name = parsed_json["last_name"]
  addresses = parsed_json["addresses"]&.map do |item|
    item = item.to_json
    Merge::Crm::Address.from_json(json_object: item)
  end
  email_addresses = parsed_json["email_addresses"]&.map do |item|
    item = item.to_json
    Merge::Crm::EmailAddress.from_json(json_object: item)
  end
  phone_numbers = parsed_json["phone_numbers"]&.map do |item|
    item = item.to_json
    Merge::Crm::PhoneNumber.from_json(json_object: item)
  end
  remote_updated_at = unless parsed_json["remote_updated_at"].nil?
                        DateTime.parse(parsed_json["remote_updated_at"])
                      end
  remote_created_at = unless parsed_json["remote_created_at"].nil?
                        DateTime.parse(parsed_json["remote_created_at"])
                      end
  converted_date = (DateTime.parse(parsed_json["converted_date"]) unless parsed_json["converted_date"].nil?)
  if parsed_json["converted_contact"].nil?
    converted_contact = nil
  else
    converted_contact = parsed_json["converted_contact"].to_json
    converted_contact = Merge::Crm::LeadConvertedContact.from_json(json_object: converted_contact)
  end
  if parsed_json["converted_account"].nil?
     = nil
  else
     = parsed_json["converted_account"].to_json
     = Merge::Crm::LeadConvertedAccount.from_json(json_object: )
  end
  remote_was_deleted = parsed_json["remote_was_deleted"]
  field_mappings = parsed_json["field_mappings"]
  remote_data = parsed_json["remote_data"]&.map do |item|
    item = item.to_json
    Merge::Crm::RemoteData.from_json(json_object: item)
  end
  remote_fields = parsed_json["remote_fields"]&.map do |item|
    item = item.to_json
    Merge::Crm::RemoteField.from_json(json_object: item)
  end
  new(
    id: id,
    remote_id: remote_id,
    created_at: created_at,
    modified_at: modified_at,
    owner: owner,
    lead_source: lead_source,
    title: title,
    company: company,
    first_name: first_name,
    last_name: last_name,
    addresses: addresses,
    email_addresses: email_addresses,
    phone_numbers: phone_numbers,
    remote_updated_at: remote_updated_at,
    remote_created_at: remote_created_at,
    converted_date: converted_date,
    converted_contact: converted_contact,
    converted_account: ,
    remote_was_deleted: remote_was_deleted,
    field_mappings: field_mappings,
    remote_data: remote_data,
    remote_fields: remote_fields,
    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.



262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
# File 'lib/merge_ruby_client/crm/types/lead.rb', line 262

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.remote_id&.is_a?(String) != false || raise("Passed value for field obj.remote_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.modified_at&.is_a?(DateTime) != false || raise("Passed value for field obj.modified_at is not the expected type, validation failed.")
  obj.owner.nil? || Merge::Crm::LeadOwner.validate_raw(obj: obj.owner)
  obj.lead_source&.is_a?(String) != false || raise("Passed value for field obj.lead_source is not the expected type, validation failed.")
  obj.title&.is_a?(String) != false || raise("Passed value for field obj.title is not the expected type, validation failed.")
  obj.company&.is_a?(String) != false || raise("Passed value for field obj.company is not the expected type, validation failed.")
  obj.first_name&.is_a?(String) != false || raise("Passed value for field obj.first_name is not the expected type, validation failed.")
  obj.last_name&.is_a?(String) != false || raise("Passed value for field obj.last_name is not the expected type, validation failed.")
  obj.addresses&.is_a?(Array) != false || raise("Passed value for field obj.addresses is not the expected type, validation failed.")
  obj.email_addresses&.is_a?(Array) != false || raise("Passed value for field obj.email_addresses is not the expected type, validation failed.")
  obj.phone_numbers&.is_a?(Array) != false || raise("Passed value for field obj.phone_numbers is not the expected type, validation failed.")
  obj.remote_updated_at&.is_a?(DateTime) != false || raise("Passed value for field obj.remote_updated_at is not the expected type, validation failed.")
  obj.remote_created_at&.is_a?(DateTime) != false || raise("Passed value for field obj.remote_created_at is not the expected type, validation failed.")
  obj.converted_date&.is_a?(DateTime) != false || raise("Passed value for field obj.converted_date is not the expected type, validation failed.")
  obj.converted_contact.nil? || Merge::Crm::LeadConvertedContact.validate_raw(obj: obj.converted_contact)
  obj..nil? || Merge::Crm::LeadConvertedAccount.validate_raw(obj: obj.)
  obj.remote_was_deleted&.is_a?(Boolean) != false || raise("Passed value for field obj.remote_was_deleted is not the expected type, validation failed.")
  obj.field_mappings&.is_a?(Hash) != false || raise("Passed value for field obj.field_mappings is not the expected type, validation failed.")
  obj.remote_data&.is_a?(Array) != false || raise("Passed value for field obj.remote_data is not the expected type, validation failed.")
  obj.remote_fields&.is_a?(Array) != false || raise("Passed value for field obj.remote_fields is not the expected type, validation failed.")
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of Lead to a JSON object



252
253
254
# File 'lib/merge_ruby_client/crm/types/lead.rb', line 252

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