Sha256: e1dfa0afa9467e314c20d2649cf8dcc7069ab521d079570e907f7030bbc87f59
Contents?: true
Size: 1.48 KB
Versions: 1
Compression:
Stored size: 1.48 KB
Contents
# frozen_string_literal: true require 'zoho_hub/records/base_record' module ZohoHub class Contact < BaseRecord attributes :id, :email, :salutation, :first_name, :mobile, :role, :last_name, :vendor_id attributes :account_id, :owner_id, :campaign_id, :status, :campaign_detail, :phone attributes :mailing_city, :mailing_zip, :mailing_country, :mailing_street :mailing_state attributes :date_of_birth, :relationship_to_business attribute_translation( id: :id, role: :platform_cont_type, status: :platform_cont_status, use_proceeds: :use_proceeds, date_of_birth: :Date_of_Birth ) DEFAULTS = { status: 'active', campaign_detail: 'Web Sign Up' }.freeze 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 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 end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
zoho_hub-0.1.36 | lib/zoho_hub/records/contact.rb |