Class: Ilinkmaker::Client
- Inherits:
-
Object
- Object
- Ilinkmaker::Client
- Includes:
- HTTParty
- Defined in:
- lib/ilinkmaker/client.rb
Instance Attribute Summary collapse
-
#linkshare_url ⇒ Object
readonly
Returns the value of attribute linkshare_url.
-
#partner_id ⇒ Object
readonly
Returns the value of attribute partner_id.
Instance Method Summary collapse
- #get_affiliate_link(result, options = {}) ⇒ Object
-
#initialize(options = {}) ⇒ Client
constructor
A new instance of Client.
- #lookup(options = {}) ⇒ Object
- #search(options = {}) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Client
Returns a new instance of Client.
10 11 12 13 |
# File 'lib/ilinkmaker/client.rb', line 10 def initialize(={}) @partner_id = [:partner_id] || Ilinkmaker.partner_id @linkshare_url = [:linkshare_url] || Ilinkmaker.linkshare_url end |
Instance Attribute Details
#linkshare_url ⇒ Object (readonly)
Returns the value of attribute linkshare_url.
8 9 10 |
# File 'lib/ilinkmaker/client.rb', line 8 def linkshare_url @linkshare_url end |
#partner_id ⇒ Object (readonly)
Returns the value of attribute partner_id.
8 9 10 |
# File 'lib/ilinkmaker/client.rb', line 8 def partner_id @partner_id end |
Instance Method Details
#get_affiliate_link(result, options = {}) ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'lib/ilinkmaker/client.rb', line 23 def get_affiliate_link(result, ={}) url = result["trackViewUrl"] if @partner_id && @linkshare_url url = "#{@linkshare_url}#{url}?partnerId=#{@partner_id}" elsif [:partner_id] && [:linkshare_url] url = "#{[:linkshare_url]}#{url}?partnerId=#{[:partner_id]}" end end |
#lookup(options = {}) ⇒ Object
19 20 21 |
# File 'lib/ilinkmaker/client.rb', line 19 def lookup(={}) response = self.class.get("/wsLookup", :query => .merge(self.)) end |
#search(options = {}) ⇒ Object
15 16 17 |
# File 'lib/ilinkmaker/client.rb', line 15 def search(={}) response = self.class.get("/wsSearch", :query => .merge(self.)) end |