Class: Merge::Crm::LeadRequest

Inherits:
Object
  • Object
show all
Defined in:
lib/merge_ruby_client/crm/types/lead_request.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(owner: OMIT, lead_source: OMIT, title: OMIT, company: OMIT, first_name: OMIT, last_name: OMIT, addresses: OMIT, email_addresses: OMIT, phone_numbers: OMIT, converted_date: OMIT, converted_contact: OMIT, converted_account: OMIT, integration_params: OMIT, linked_account_params: OMIT, remote_fields: OMIT, additional_properties: nil) ⇒ Merge::Crm::LeadRequest

Parameters:

  • owner (Merge::Crm::LeadRequestOwner) (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::AddressRequest>) (defaults to: OMIT)
  • email_addresses (Array<Merge::Crm::EmailAddressRequest>) (defaults to: OMIT)
  • phone_numbers (Array<Merge::Crm::PhoneNumberRequest>) (defaults to: OMIT)
  • converted_date (DateTime) (defaults to: OMIT)

    When the lead was converted.

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

    The contact of the converted lead.

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

    The account of the converted lead.

  • integration_params (Hash{String => Object}) (defaults to: OMIT)
  • linked_account_params (Hash{String => Object}) (defaults to: OMIT)
  • remote_fields (Array<Merge::Crm::RemoteFieldRequest>) (defaults to: OMIT)
  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



78
79
80
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
# File 'lib/merge_ruby_client/crm/types/lead_request.rb', line 78

def initialize(owner: OMIT, lead_source: OMIT, title: OMIT, company: OMIT, first_name: OMIT, last_name: OMIT,
               addresses: OMIT, email_addresses: OMIT, phone_numbers: OMIT, converted_date: OMIT, converted_contact: OMIT, converted_account: OMIT, integration_params: OMIT, linked_account_params: OMIT, remote_fields: OMIT, additional_properties: nil)
  @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
  @converted_date = converted_date if converted_date != OMIT
  @converted_contact = converted_contact if converted_contact != OMIT
  @converted_account =  if  != OMIT
  @integration_params = integration_params if integration_params != OMIT
  @linked_account_params =  if  != OMIT
  @remote_fields = remote_fields if remote_fields != OMIT
  @additional_properties = additional_properties
  @_field_set = {
    "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,
    "converted_date": converted_date,
    "converted_contact": converted_contact,
    "converted_account": ,
    "integration_params": integration_params,
    "linked_account_params": ,
    "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



54
55
56
# File 'lib/merge_ruby_client/crm/types/lead_request.rb', line 54

def additional_properties
  @additional_properties
end

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

Returns:



36
37
38
# File 'lib/merge_ruby_client/crm/types/lead_request.rb', line 36

def addresses
  @addresses
end

#companyString (readonly)

Returns The lead’s company.

Returns:

  • (String)

    The lead’s company.



30
31
32
# File 'lib/merge_ruby_client/crm/types/lead_request.rb', line 30

def company
  @company
end

#converted_accountMerge::Crm::LeadRequestConvertedAccount (readonly)

Returns The account of the converted lead.

Returns:



46
47
48
# File 'lib/merge_ruby_client/crm/types/lead_request.rb', line 46

def 
  @converted_account
end

#converted_contactMerge::Crm::LeadRequestConvertedContact (readonly)

Returns The contact of the converted lead.

Returns:



44
45
46
# File 'lib/merge_ruby_client/crm/types/lead_request.rb', line 44

def converted_contact
  @converted_contact
end

#converted_dateDateTime (readonly)

Returns When the lead was converted.

Returns:

  • (DateTime)

    When the lead was converted.



42
43
44
# File 'lib/merge_ruby_client/crm/types/lead_request.rb', line 42

def converted_date
  @converted_date
end

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



38
39
40
# File 'lib/merge_ruby_client/crm/types/lead_request.rb', line 38

def email_addresses
  @email_addresses
end

#first_nameString (readonly)

Returns The lead’s first name.

Returns:

  • (String)

    The lead’s first name.



32
33
34
# File 'lib/merge_ruby_client/crm/types/lead_request.rb', line 32

def first_name
  @first_name
end

#integration_paramsHash{String => Object} (readonly)

Returns:

  • (Hash{String => Object})


48
49
50
# File 'lib/merge_ruby_client/crm/types/lead_request.rb', line 48

def integration_params
  @integration_params
end

#last_nameString (readonly)

Returns The lead’s last name.

Returns:

  • (String)

    The lead’s last name.



34
35
36
# File 'lib/merge_ruby_client/crm/types/lead_request.rb', line 34

def last_name
  @last_name
end

#lead_sourceString (readonly)

Returns The lead’s source.

Returns:

  • (String)

    The lead’s source.



26
27
28
# File 'lib/merge_ruby_client/crm/types/lead_request.rb', line 26

def lead_source
  @lead_source
end

#linked_account_paramsHash{String => Object} (readonly)

Returns:

  • (Hash{String => Object})


50
51
52
# File 'lib/merge_ruby_client/crm/types/lead_request.rb', line 50

def 
  @linked_account_params
end

#ownerMerge::Crm::LeadRequestOwner (readonly)

Returns The lead’s owner.

Returns:



24
25
26
# File 'lib/merge_ruby_client/crm/types/lead_request.rb', line 24

def owner
  @owner
end

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

Returns:



40
41
42
# File 'lib/merge_ruby_client/crm/types/lead_request.rb', line 40

def phone_numbers
  @phone_numbers
end

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

Returns:



52
53
54
# File 'lib/merge_ruby_client/crm/types/lead_request.rb', line 52

def remote_fields
  @remote_fields
end

#titleString (readonly)

Returns The lead’s title.

Returns:

  • (String)

    The lead’s title.



28
29
30
# File 'lib/merge_ruby_client/crm/types/lead_request.rb', line 28

def title
  @title
end

Class Method Details

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

Deserialize a JSON object to an instance of LeadRequest

Parameters:

  • json_object (String)

Returns:



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
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
# File 'lib/merge_ruby_client/crm/types/lead_request.rb', line 121

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  if parsed_json["owner"].nil?
    owner = nil
  else
    owner = parsed_json["owner"].to_json
    owner = Merge::Crm::LeadRequestOwner.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::AddressRequest.from_json(json_object: item)
  end
  email_addresses = parsed_json["email_addresses"]&.map do |item|
    item = item.to_json
    Merge::Crm::EmailAddressRequest.from_json(json_object: item)
  end
  phone_numbers = parsed_json["phone_numbers"]&.map do |item|
    item = item.to_json
    Merge::Crm::PhoneNumberRequest.from_json(json_object: item)
  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::LeadRequestConvertedContact.from_json(json_object: converted_contact)
  end
  if parsed_json["converted_account"].nil?
     = nil
  else
     = parsed_json["converted_account"].to_json
     = Merge::Crm::LeadRequestConvertedAccount.from_json(json_object: )
  end
  integration_params = parsed_json["integration_params"]
   = parsed_json["linked_account_params"]
  remote_fields = parsed_json["remote_fields"]&.map do |item|
    item = item.to_json
    Merge::Crm::RemoteFieldRequest.from_json(json_object: item)
  end
  new(
    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,
    converted_date: converted_date,
    converted_contact: converted_contact,
    converted_account: ,
    integration_params: integration_params,
    linked_account_params: ,
    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)


199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
# File 'lib/merge_ruby_client/crm/types/lead_request.rb', line 199

def self.validate_raw(obj:)
  obj.owner.nil? || Merge::Crm::LeadRequestOwner.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.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::LeadRequestConvertedContact.validate_raw(obj: obj.converted_contact)
  obj..nil? || Merge::Crm::LeadRequestConvertedAccount.validate_raw(obj: obj.)
  obj.integration_params&.is_a?(Hash) != false || raise("Passed value for field obj.integration_params is not the expected type, validation failed.")
  obj.&.is_a?(Hash) != false || raise("Passed value for field obj.linked_account_params 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 LeadRequest to a JSON object

Returns:

  • (String)


189
190
191
# File 'lib/merge_ruby_client/crm/types/lead_request.rb', line 189

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