module Access class Favorite def self.process_batch(chunk) chunk.map { |favorite| new(favorite) } end def initialize(values) self.class.class_eval {attr_reader *values.keys } values.each do |attribute_name, attribute_value| self.instance_variable_set("@#{attribute_name}", attribute_value) end end def resource self.send(self.favoriteType) end def self.search(options = {}) Access::Api.new.favorites_search options end def self.search_offers(options = {}) Access::Api.new.favorites_search options.merge(favorite_type: 'offers') end def self.search_locations(options = {}) Access::Api.new.favorites_search options.merge(favorite_type: 'locations') end def self.search_stores(options = {}) Access::Api.new.favorites_search options.merge(favorite_type: 'stores') end def self.find_offer(offer_key, options = {}) Access::Api.new.favorites_find offer_key, options.merge(favorite_type: 'offers') end def self.find_location(location_key, options = {}) Access::Api.new.favorites_find location_key, options.merge(favorite_type: 'locations') end def self.find_store(store_key, options = {}) Access::Api.new.favorites_find store_key, options.merge(favorite_type: 'stores') end def self.create_offer(offer_key, options = {}) Access::Api.new.favorites_create offer_key, options.merge(favorite_type: 'offers') end def self.create_location(location_key, options = {}) Access::Api.new.favorites_create location_key, options.merge(favorite_type: 'locations') end def self.create_store(store_key, options = {}) Access::Api.new.favorites_create store_key, options.merge(favorite_type: 'stores') end def self.delete_offer(offer_key, options = {}) Access::Api.new.favorites_delete offer_key, options.merge(favorite_type: 'offers') end def self.delete_location(location_key, options = {}) Access::Api.new.favorites_delete location_key, options.merge(favorite_type: 'locations') end def self.delete_store(store_key, options = {}) Access::Api.new.favorites_delete store_key, options.merge(favorite_type: 'stores') end end end