Sha256: 0f41b8dc98ad53e369b700e752e9dcc172f40bf786547b08ad0ed138a5907010

Contents?: true

Size: 804 Bytes

Versions: 11

Compression:

Stored size: 804 Bytes

Contents

# frozen_string_literal: true

require 'zoho_hub/records/base_record'

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

    attribute_translation(
      id: :id,
      stage: :Quote_Stage
    )

    def initialize(params)
      puts Rainbow(params).bright.red
      attributes.each do |attr|
        zoho_key = attr_to_zoho_key(attr)

        send("#{attr}=", params[zoho_key] || params[attr])
      end

      @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

11 entries across 11 versions & 1 rubygems

Version Path
zoho_hub-0.1.15 lib/zoho_hub/records/quote.rb
zoho_hub-0.1.14 lib/zoho_hub/records/quote.rb
zoho_hub-0.1.13 lib/zoho_hub/records/quote.rb
zoho_hub-0.1.12 lib/zoho_hub/records/quote.rb
zoho_hub-0.1.11 lib/zoho_hub/records/quote.rb
zoho_hub-0.2.0 lib/zoho_hub/deprecated_and_only_for_reference_records/quote.rb
zoho_hub-0.1.10 lib/zoho_hub/records/quote.rb
zoho_hub-0.1.9 lib/zoho_hub/deprecated_and_only_for_reference_records/quote.rb
zoho_hub-0.1.8 lib/zoho_hub/records/quote.rb
zoho_hub-0.1.7 lib/zoho_hub/records/quote.rb
zoho_hub-0.1.6 lib/zoho_hub/records/quote.rb