Class: ZohoHub::Contact
- Inherits:
-
BaseRecord
- Object
- BaseRecord
- ZohoHub::Contact
- Defined in:
- lib/zoho_hub/records/contact.rb
Constant Summary collapse
- DEFAULTS =
{ status: 'active', campaign_detail: 'Web Sign Up' }.freeze
Instance Method Summary collapse
-
#initialize(params) ⇒ Contact
constructor
A new instance of Contact.
- #to_params ⇒ Object
Methods inherited from BaseRecord
all, attribute_translation, attributes, #attributes, #build_response, build_response, create, exists?, find, find_by, #get, get, #new_record?, post, #post, put, #put, request_path, #save, #to_input, where, zoho_key_translation
Constructor Details
#initialize(params) ⇒ Contact
Returns a new instance of Contact.
26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/zoho_hub/records/contact.rb', line 26 def initialize(params) attributes.each do |attr| zoho_key = attr_to_zoho_key(attr) send("#{attr}=", params[zoho_key] || params[attr] || DEFAULTS[attr]) end # Setup values as they come from the Zoho API if needed @account_id ||= params.dig(:Account_Name, :id) @owner_id ||= params.dig(:Owner, :id) @campaign_id ||= params.dig(:Campaign_Lookup, :id) @vendor_id ||= params.dig(:Vendor_Name, :id) end |
Instance Method Details
#to_params ⇒ Object
40 41 42 43 44 45 46 47 48 49 |
# File 'lib/zoho_hub/records/contact.rb', line 40 def to_params params = super params[:Account_Name] = { id: @account_id } if @account_id params[:Owner] = { id: @owner_id } if @owner_id params[:Campaign_Lookup] = { id: @campaign_id } if @campaign_id params[:Vendor_Name] = { id: @vendor_id } if @vendor_id params end |