Sha256: 9ee3943272fc4ee6fafbd11cd5f3cf9b658e26ea5eab3d7e1564cd8e5e40d59d

Contents?: true

Size: 819 Bytes

Versions: 4

Compression:

Stored size: 819 Bytes

Contents

# frozen_string_literal: true

require 'zoho_hub/records/base_record'

module ZohoHub
  class Quote < BaseRecord
    attributes :id, :stage, :subject, :potential_id

    # The translation from attribute name to the JSON field on Zoho. The default behaviour will be
    # to Camel_Case the attribute so on this list we should only have exceptions to this rule.
    attribute_translation(
      id: :id,
      stage: :Quote_Stage
    )

    def initialize(params = {})
      super

      @potential_id ||= params.dig(:Deal_Name, :id)
      @lender_organisation_id ||= params.dig(:Account_Name, :id)
    end

    def to_params
      params = super

      params[:Deal_Name] = { id: @potential_id } if @potential_id
      params[:Account_Name] = { id: @lender_organisation_id } if @lender_organisation_id
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
zoho_hub-0.4.2 examples/models/quote.rb
zoho_hub-0.4.1 examples/models/quote.rb
zoho_hub-0.4.0 examples/models/quote.rb
zoho_hub-0.3.0 examples/models/quote.rb