Sha256: cbd6582b8413f540dbaa534f04cc6612e83c99f8bc5777cc6bb0b87b7766fc82

Contents?: true

Size: 718 Bytes

Versions: 12

Compression:

Stored size: 718 Bytes

Contents

# frozen_string_literal: true

module ZohoHub
  class Vendor < BaseRecord
    attributes :id, :email, :description, :vendor_name, :website, :owner_id, :phone, :currency
    attributes :company_reg_no, :created_time, :modified_time, :lender_status

    attribute_translation(
      id: :id
    )

    DEFAULTS = {
      currency: 'GBP'
    }.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

      @owner_id ||= params.dig(:Owner, :id)
    end

    def to_params
      params = super

      params[:Owner] = { id: @owner_id } if @owner_id

      params
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

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