Class: Linkshare::Coupon
- Inherits:
-
Object
- Object
- Linkshare::Coupon
- Defined in:
- lib/linkshare/coupon.rb
Instance Method Summary collapse
- #fetch ⇒ Object
- #getCoupons ⇒ Object
- #getPageNumberRequested ⇒ Object
- #getTotalMatches ⇒ Object
- #getTotalPages ⇒ Object
-
#initialize(query = {}) ⇒ Coupon
constructor
A new instance of Coupon.
- #query(query) ⇒ Object
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
#fetch ⇒ Object
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 |
#getCoupons ⇒ Object
22 23 24 |
# File 'lib/linkshare/coupon.rb', line 22 def getCoupons() @coupons end |
#getPageNumberRequested ⇒ Object
18 19 20 |
# File 'lib/linkshare/coupon.rb', line 18 def getPageNumberRequested() @pageNumberRequested end |
#getTotalMatches ⇒ Object
10 11 12 |
# File 'lib/linkshare/coupon.rb', line 10 def getTotalMatches() @totalMatches end |
#getTotalPages ⇒ Object
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 |