Sha256: 04bd397dfff4ee3ff1b3095f3d74cdde443fdde8743e98c5e48150d769779bd4

Contents?: true

Size: 1.16 KB

Versions: 35

Compression:

Stored size: 1.16 KB

Contents

module SparkApi
  module Models
    class SharedLink < Base
      extend Finders

      attr_accessor :sort_id
      attr_writer :name

      self.element_name = "sharedlinks"

      def self.create(data)
        SharedLink.new SparkApi.client.post("#{path}/#{resource_type(data)}", data).first
      rescue SparkApi::BadResourceRequest
        false
      end

      def name
        if @name
          @name
        elsif respond_to?(:ListingCart) && self.ListingCart.respond_to?(:Name)
          self.ListingCart.Name
        elsif respond_to?(:SavedSearch) && self.SavedSearch.respond_to?(:Name)
          self.SavedSearch.Name
        end
      end

      def template
        if respond_to?(:SavedSearch) && self.SavedSearch.respond_to?(:template)
          self.SavedSearch.template
        end
      end

      def filter
        "SharedLink Eq '#{id}'"
      end

      def listing_search_role
        self.Mode.downcase.to_sym
      end

      private

      def self.resource_type(data)
        case data.keys[0].to_sym
          when :ListingIds; "listings"
          when :SearchId;   "search"
          when :CartId;     "cart"
        end
      end

    end
  end
end

Version data entries

35 entries across 35 versions & 1 rubygems

Version Path
spark_api-1.6.3 lib/spark_api/models/shared_link.rb
spark_api-1.6.2 lib/spark_api/models/shared_link.rb
spark_api-1.6.1 lib/spark_api/models/shared_link.rb
spark_api-1.5.7 lib/spark_api/models/shared_link.rb
spark_api-1.6.0 lib/spark_api/models/shared_link.rb
spark_api-1.5.6 lib/spark_api/models/shared_link.rb
spark_api-1.5.5 lib/spark_api/models/shared_link.rb
spark_api-1.5.4 lib/spark_api/models/shared_link.rb
spark_api-1.5.3 lib/spark_api/models/shared_link.rb
spark_api-1.5.2 lib/spark_api/models/shared_link.rb
spark_api-1.5.1 lib/spark_api/models/shared_link.rb
spark_api-1.5.0 lib/spark_api/models/shared_link.rb
spark_api-1.4.34 lib/spark_api/models/shared_link.rb
spark_api-1.4.32 lib/spark_api/models/shared_link.rb
spark_api-1.4.31 lib/spark_api/models/shared_link.rb
spark_api-1.4.29 lib/spark_api/models/shared_link.rb
spark_api-1.4.28 lib/spark_api/models/shared_link.rb
spark_api-1.4.27 lib/spark_api/models/shared_link.rb
spark_api-1.4.26 lib/spark_api/models/shared_link.rb
spark_api-1.4.25 lib/spark_api/models/shared_link.rb