Sha256: 8bc64fe8d79e7c23d7e2efc8eef4cdd9b59129a8fb6abba57f17f646a7716d91

Contents?: true

Size: 1.88 KB

Versions: 2

Compression:

Stored size: 1.88 KB

Contents

module SparkApi
  module Models
    class Contact < Base
      extend Finders
      include Concerns::Savable,
              Concerns::Destroyable

      self.element_name="contacts"

      def self.by_tag(tag_name, arguments={})
        collect(connection.get("#{path}/tags/#{tag_name}", arguments))
      end

      def self.tags(arguments={})
        connection.get("#{path}/tags", arguments)
      end

      def self.my(arguments={})
        new(connection.get('/my/contact', arguments).first)
      end
            
      def self.export(arguments={})
        collect(connection.get("/contacts/export", arguments))
      end

      def self.export_all(arguments={})
        collect(connection.get("/contacts/export/all", arguments))
      end

      # Notify the agent of contact creation via a Spark notification.
      def notify?; params_for_save[:Notify] == true end
      def notify=(notify_me)
        params_for_save[:Notify] = notify_me
      end

      def saved_searches(arguments = {})
        @saved_searches ||= SavedSearch.collect(connection.get("/contacts/#{self.Id}/savedsearches", arguments))
      end

      def listing_carts(arguments = {})
        @listing_carts ||= ListingCart.collect(connection.get("/contacts/#{self.Id}/listingcarts", arguments))
      end

      def comments(arguments = {})
        @comments ||= Comment.collect(connection.get("/contacts/#{self.Id}/comments", arguments))
      end
      def comment(body)
        comment = Comment.new({ :Comment => body })
        comment.parent = self
        comment.save
        comment
      end

      def vow_account(arguments={})
        return @vow_account if @vow_account
        begin
          @vow_account = VowAccount.new(connection.get("/contacts/#{self.Id}/portal", arguments).first)
          @vow_account.parent = self
          @vow_account
        rescue NotFound
          nil
        end
      end
      
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
spark_api-1.3.1 lib/spark_api/models/contact.rb
spark_api-1.3.0 lib/spark_api/models/contact.rb