Class: Merge::Crm::Lead
- Inherits:
-
Object
- Object
- Merge::Crm::Lead
- 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
-
#additional_properties ⇒ OpenStruct
readonly
Additional properties unmapped to the current class definition.
- #addresses ⇒ Array<Merge::Crm::Address> readonly
-
#company ⇒ String
readonly
The lead’s company.
-
#converted_account ⇒ Merge::Crm::LeadConvertedAccount
readonly
The account of the converted lead.
-
#converted_contact ⇒ Merge::Crm::LeadConvertedContact
readonly
The contact of the converted lead.
-
#converted_date ⇒ DateTime
readonly
When the lead was converted.
-
#created_at ⇒ DateTime
readonly
The datetime that this object was created by Merge.
- #email_addresses ⇒ Array<Merge::Crm::EmailAddress> readonly
- #field_mappings ⇒ Hash{String => Object} readonly
-
#first_name ⇒ String
readonly
The lead’s first name.
- #id ⇒ String readonly
-
#last_name ⇒ String
readonly
The lead’s last name.
-
#lead_source ⇒ String
readonly
The lead’s source.
-
#modified_at ⇒ DateTime
readonly
The datetime that this object was modified by Merge.
-
#owner ⇒ Merge::Crm::LeadOwner
readonly
The lead’s owner.
- #phone_numbers ⇒ Array<Merge::Crm::PhoneNumber> readonly
-
#remote_created_at ⇒ DateTime
readonly
When the third party’s lead was created.
- #remote_data ⇒ Array<Merge::Crm::RemoteData> readonly
- #remote_fields ⇒ Array<Merge::Crm::RemoteField> readonly
-
#remote_id ⇒ String
readonly
The third-party API ID of the matching object.
-
#remote_updated_at ⇒ DateTime
readonly
When the third party’s lead was updated.
- #remote_was_deleted ⇒ Boolean readonly
-
#title ⇒ String
readonly
The lead’s title.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ Merge::Crm::Lead
Deserialize a JSON object to an instance of Lead.
-
.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.
Instance Method Summary collapse
- #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 constructor
-
#to_json(*_args) ⇒ String
Serialize an instance of Lead to a JSON object.
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
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 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 |
# File 'lib/merge_ruby_client/crm/types/lead.rb', line 100 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 = converted_account if converted_account != 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": 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_properties ⇒ OpenStruct (readonly)
Returns Additional properties unmapped to the current class definition.
69 70 71 |
# File 'lib/merge_ruby_client/crm/types/lead.rb', line 69 def additional_properties @additional_properties end |
#addresses ⇒ Array<Merge::Crm::Address> (readonly)
45 46 47 |
# File 'lib/merge_ruby_client/crm/types/lead.rb', line 45 def addresses @addresses end |
#company ⇒ String (readonly)
Returns The lead’s company.
39 40 41 |
# File 'lib/merge_ruby_client/crm/types/lead.rb', line 39 def company @company end |
#converted_account ⇒ Merge::Crm::LeadConvertedAccount (readonly)
Returns The account of the converted lead.
59 60 61 |
# File 'lib/merge_ruby_client/crm/types/lead.rb', line 59 def converted_account @converted_account end |
#converted_contact ⇒ Merge::Crm::LeadConvertedContact (readonly)
Returns The contact of the converted lead.
57 58 59 |
# File 'lib/merge_ruby_client/crm/types/lead.rb', line 57 def converted_contact @converted_contact end |
#converted_date ⇒ DateTime (readonly)
Returns 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_at ⇒ DateTime (readonly)
Returns 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_addresses ⇒ Array<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_mappings ⇒ Hash{String => Object} (readonly)
63 64 65 |
# File 'lib/merge_ruby_client/crm/types/lead.rb', line 63 def field_mappings @field_mappings end |
#first_name ⇒ String (readonly)
Returns 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 |
#id ⇒ String (readonly)
25 26 27 |
# File 'lib/merge_ruby_client/crm/types/lead.rb', line 25 def id @id end |
#last_name ⇒ String (readonly)
Returns 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_source ⇒ String (readonly)
Returns 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_at ⇒ DateTime (readonly)
Returns 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 |
#owner ⇒ Merge::Crm::LeadOwner (readonly)
Returns The lead’s owner.
33 34 35 |
# File 'lib/merge_ruby_client/crm/types/lead.rb', line 33 def owner @owner end |
#phone_numbers ⇒ Array<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_at ⇒ DateTime (readonly)
Returns 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_data ⇒ Array<Merge::Crm::RemoteData> (readonly)
65 66 67 |
# File 'lib/merge_ruby_client/crm/types/lead.rb', line 65 def remote_data @remote_data end |
#remote_fields ⇒ Array<Merge::Crm::RemoteField> (readonly)
67 68 69 |
# File 'lib/merge_ruby_client/crm/types/lead.rb', line 67 def remote_fields @remote_fields end |
#remote_id ⇒ String (readonly)
Returns 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_at ⇒ DateTime (readonly)
Returns 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_deleted ⇒ Boolean (readonly)
61 62 63 |
# File 'lib/merge_ruby_client/crm/types/lead.rb', line 61 def remote_was_deleted @remote_was_deleted end |
#title ⇒ String (readonly)
Returns 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
157 158 159 160 161 162 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 |
# File 'lib/merge_ruby_client/crm/types/lead.rb', line 157 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? converted_account = nil else converted_account = parsed_json["converted_account"].to_json converted_account = Merge::Crm::LeadConvertedAccount.from_json(json_object: converted_account) 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: 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.
256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 |
# File 'lib/merge_ruby_client/crm/types/lead.rb', line 256 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.converted_account.nil? || Merge::Crm::LeadConvertedAccount.validate_raw(obj: obj.converted_account) 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
246 247 248 |
# File 'lib/merge_ruby_client/crm/types/lead.rb', line 246 def to_json(*_args) @_field_set&.to_json end |