Class: Ilinkmaker::Client

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/ilinkmaker/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Client

Returns a new instance of Client.



10
11
12
13
# File 'lib/ilinkmaker/client.rb', line 10

def initialize(options={})
  @partner_id = options[:partner_id] || Ilinkmaker.partner_id
  @linkshare_url = options[:linkshare_url] || Ilinkmaker.linkshare_url
end

Instance Attribute Details

#linkshare_urlObject (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_idObject (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



23
24
25
26
27
28
29
30
31
# File 'lib/ilinkmaker/client.rb', line 23

def get_affiliate_link(result, options={})
  url = result["trackViewUrl"]
  
  if @partner_id && @linkshare_url        
    url = "#{@linkshare_url}#{url}?partner_id=#{@partner_id}"
  elsif options[:partner_id] && options[:linkshare_url]
    url = "#{options[:linkshare_url]}#{url}?partner_id=#{options[:partner_id]}"
  end
end

#lookup(options = {}) ⇒ Object



19
20
21
# File 'lib/ilinkmaker/client.rb', line 19

def lookup(options={})
  response = self.class.get("/wsLookup", :query => options.merge(self.default_options))
end

#search(options = {}) ⇒ Object



15
16
17
# File 'lib/ilinkmaker/client.rb', line 15

def search(options={})
  response = self.class.get("/wsSearch", :query => options.merge(self.default_options))
end