Sha256: 64c8fa824a6014d5842c845b14b1fec3e36598e53d2a62c82100fd1a546acbf4

Contents?: true

Size: 785 Bytes

Versions: 13

Compression:

Stored size: 785 Bytes

Contents

# frozen_string_literal: true

require 'zoho_hub/records/base_record'

module ZohoHub
  class SMSMessage < BaseRecord
    attributes :id, :template, :state, :text, :contact_id, :potential_id, :name, :sent_by

    attribute_translation id: :id

    def initialize(params)
      attributes.each do |attr|
        zoho_key = attr_to_zoho_key(attr)

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

      # Setup values as they come from the Zoho API if needed
      @contact_id ||= params.dig(:Contact, :id)
      @potential_id ||= params.dig(:Potential, :id)
    end

    def to_params
      params = super

      params[:Contact] = { id: @contact_id } if @contact_id
      params[:Potential] = { id: @potential_id } if @potential_id

      params
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
zoho_hub-0.1.56 lib/zoho_hub/records/sms_message.rb
zoho_hub-0.1.55 lib/zoho_hub/records/sms_message.rb
zoho_hub-0.1.54 lib/zoho_hub/records/sms_message.rb
zoho_hub-0.1.53 lib/zoho_hub/records/sms_message.rb
zoho_hub-0.1.52 lib/zoho_hub/records/sms_message.rb
zoho_hub-0.1.51 lib/zoho_hub/records/sms_message.rb
zoho_hub-0.1.50 lib/zoho_hub/records/sms_message.rb
zoho_hub-0.1.49 lib/zoho_hub/records/sms_message.rb
zoho_hub-0.1.48 lib/zoho_hub/records/sms_message.rb
zoho_hub-0.1.47 lib/zoho_hub/records/sms_message.rb
zoho_hub-0.1.46 lib/zoho_hub/records/sms_message.rb
zoho_hub-0.1.45 lib/zoho_hub/records/sms_message.rb
zoho_hub-0.1.44 lib/zoho_hub/records/sms_message.rb