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

Parameters:

  • id (String) (defaults to: OMIT)
  • remote_id (String) (defaults to: OMIT)

    The third-party API ID of the matching object.

  • created_at (DateTime) (defaults to: OMIT)

    The datetime that this object was created by Merge.

  • modified_at (DateTime) (defaults to: OMIT)

    The datetime that this object was modified by Merge.

  • owner (Merge::Crm::LeadOwner) (defaults to: OMIT)

    The lead’s owner.

  • lead_source (String) (defaults to: OMIT)

    The lead’s source.

  • title (String) (defaults to: OMIT)

    The lead’s title.

  • company (String) (defaults to: OMIT)

    The lead’s company.

  • first_name (String) (defaults to: OMIT)

    The lead’s first name.

  • last_name (String) (defaults to: OMIT)

    The lead’s last name.

  • addresses (Array<Merge::Crm::Address>) (defaults to: OMIT)
  • email_addresses (Array<Merge::Crm::EmailAddress>) (defaults to: OMIT)
  • phone_numbers (Array<Merge::Crm::PhoneNumber>) (defaults to: OMIT)
  • remote_updated_at (DateTime) (defaults to: OMIT)

    When the third party’s lead was updated.

  • remote_created_at (DateTime) (defaults to: OMIT)

    When the third party’s lead was created.

  • converted_date (DateTime) (defaults to: OMIT)

    When the lead was converted.

  • converted_contact (Merge::Crm::LeadConvertedContact) (defaults to: OMIT)

    The contact of the converted lead.

  • converted_account (Merge::Crm::LeadConvertedAccount) (defaults to: OMIT)

    The account of the converted lead.

  • remote_was_deleted (Boolean) (defaults to: OMIT)

    Indicates whether or not this object has been deleted in the third party platform. Full coverage deletion detection is a premium add-on. Native deletion detection is offered for free with limited coverage. [Learn more](docs.merge.dev/integrations/hris/supported-features/).

  • field_mappings (Hash{String => Object}) (defaults to: OMIT)
  • remote_data (Array<Merge::Crm::RemoteData>) (defaults to: OMIT)
  • remote_fields (Array<Merge::Crm::RemoteField>) (defaults to: OMIT)
  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



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
  @converted_account =  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)

Returns Additional properties unmapped to the current class definition.

Returns:

  • (OpenStruct)

    Additional properties unmapped to the current class definition



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)

Returns:



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

def addresses
  @addresses
end

#companyString (readonly)

Returns The lead’s company.

Returns:

  • (String)

    The lead’s company.



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

def company
  @company
end

#converted_accountMerge::Crm::LeadConvertedAccount (readonly)

Returns The account of the converted lead.

Returns:



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

def 
  @converted_account
end

#converted_contactMerge::Crm::LeadConvertedContact (readonly)

Returns The contact of the converted lead.

Returns:



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

def converted_contact
  @converted_contact
end

#converted_dateDateTime (readonly)

Returns When the lead was converted.

Returns:

  • (DateTime)

    When the lead was converted.



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

def converted_date
  @converted_date
end

#created_atDateTime (readonly)

Returns The datetime that this object was created by Merge.

Returns:

  • (DateTime)

    The datetime that this object was created by Merge.



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)

Returns:



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)

Returns:

  • (Hash{String => Object})


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

def field_mappings
  @field_mappings
end

#first_nameString (readonly)

Returns The lead’s first name.

Returns:

  • (String)

    The lead’s first name.



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

def first_name
  @first_name
end

#idString (readonly)

Returns:

  • (String)


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

def id
  @id
end

#last_nameString (readonly)

Returns The lead’s last name.

Returns:

  • (String)

    The lead’s last name.



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

def last_name
  @last_name
end

#lead_sourceString (readonly)

Returns The lead’s source.

Returns:

  • (String)

    The lead’s source.



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

def lead_source
  @lead_source
end

#modified_atDateTime (readonly)

Returns The datetime that this object was modified by Merge.

Returns:

  • (DateTime)

    The datetime that this object was modified by Merge.



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

def modified_at
  @modified_at
end

#ownerMerge::Crm::LeadOwner (readonly)

Returns The lead’s owner.

Returns:



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

def owner
  @owner
end

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

Returns:



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

def phone_numbers
  @phone_numbers
end

#remote_created_atDateTime (readonly)

Returns When the third party’s lead was created.

Returns:

  • (DateTime)

    When the third party’s lead was created.



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)

Returns:



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)

Returns:



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

def remote_fields
  @remote_fields
end

#remote_idString (readonly)

Returns The third-party API ID of the matching object.

Returns:

  • (String)

    The third-party API ID of the matching object.



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

def remote_id
  @remote_id
end

#remote_updated_atDateTime (readonly)

Returns When the third party’s lead was updated.

Returns:

  • (DateTime)

    When the third party’s lead was updated.



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)

Returns Indicates whether or not this object has been deleted in the third party platform. Full coverage deletion detection is a premium add-on. Native deletion detection is offered for free with limited coverage. [Learn more](docs.merge.dev/integrations/hris/supported-features/).

Returns:

  • (Boolean)

    Indicates whether or not this object has been deleted in the third party platform. Full coverage deletion detection is a premium add-on. Native deletion detection is offered for free with limited coverage. [Learn more](docs.merge.dev/integrations/hris/supported-features/).



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

def remote_was_deleted
  @remote_was_deleted
end

#titleString (readonly)

Returns The lead’s title.

Returns:

  • (String)

    The lead’s title.



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

Parameters:

  • json_object (String)

Returns:



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.

Parameters:

  • obj (Object)

Returns:

  • (Void)


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

Returns:

  • (String)


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

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