Class: Linkshare::Coupon

Inherits:
Object
  • Object
show all
Defined in:
lib/linkshare/coupon.rb

Instance Method Summary collapse

Constructor Details

#initialize(query = {}) ⇒ Coupon

Returns a new instance of Coupon.



3
4
5
6
7
8
9
# File 'lib/linkshare/coupon.rb', line 3

def initialize (query = {})
	@totalMatches = 0
	@totalPages = 0
	@pageNumberRequested = 0
	@coupons = []
	@query = query
end

Instance Method Details

#fetchObject



29
30
31
32
33
34
35
# File 'lib/linkshare/coupon.rb', line 29

def fetch()
	data = Linkshare::Response.parse(Linkshare::Request.get(Linkshare::API_URIS[:coupon], :params => @query))
	@totalMatches = data["couponfeed"]["TotalMatches"]
	@totalPages = data["couponfeed"]["TotalPages"]
	@pageNumberRequested = data["couponfeed"]["PageNumberRequested"]
	@coupons = data["couponfeed"]["link"]
end

#getCouponsObject



22
23
24
# File 'lib/linkshare/coupon.rb', line 22

def getCoupons()
	@coupons
end

#getPageNumberRequestedObject



18
19
20
# File 'lib/linkshare/coupon.rb', line 18

def getPageNumberRequested()
	@pageNumberRequested
end

#getTotalMatchesObject



10
11
12
# File 'lib/linkshare/coupon.rb', line 10

def getTotalMatches()
	@totalMatches
end

#getTotalPagesObject



14
15
16
# File 'lib/linkshare/coupon.rb', line 14

def getTotalPages()
	@totalPages
end

#query(query) ⇒ Object



25
26
27
# File 'lib/linkshare/coupon.rb', line 25

def query(query)
	@query = query
end