Sha256: 1231f69e2aac71cf7d368cf8144077ed0c4085d8ba6f019700eff63ff3eeaaab

Contents?: true

Size: 1 KB

Versions: 14

Compression:

Stored size: 1 KB

Contents

module Access
  class Offer
    include Access::MuchMeta

    attr_reader :store, :location

    def self.search(options = {})
      Access::Api.new.search_offers options
    end

    def self.find(offer_key, options = {})
      Access::Api.new.find_offer offer_key, options
    end

    def self.find_uses_remaining(offer_key, options = {})
      Access::Api.new.find_offer_uses_remaining offer_key, options
    end

    def self.process_batch(chunk)
      chunk.map { |offer| new(offer) }
    end

    def initialize(values)
      @used_fields = []
      set_up_methods(values)
      set_values(values)
      @categories = Access::Category.process_batch(@categories) if @categories
      @links = Access::Link.new(@links) if @links
      @offer_store = Access::Store.new(@offer_store) if @offer_store
      @offer_uses_remaining = Access::Redemption.new(@offer_uses_remaining) if @offer_uses_remaining
    end

    def location
      @offer_store.physical_location
    end

    def store
      @offer_store
    end

  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
access-2.3.0.pre.rc2 lib/access/offer.rb
access-2.3.0.pre.rc1 lib/access/offer.rb
access-2.2.0 lib/access/offer.rb
access-2.1.5 lib/access/offer.rb
access-2.1.4 lib/access/offer.rb
access-2.1.3 lib/access/offer.rb
access-2.1.2 lib/access/offer.rb
access-2.1.1 lib/access/offer.rb
access-2.1.0 lib/access/offer.rb
access-2.0.55 lib/access/offer.rb
access-2.0.54 lib/access/offer.rb
access-2.0.53 lib/access/offer.rb
access-2.0.52 lib/access/offer.rb
access-2.0.51 lib/access/offer.rb