Sha256: 57cda12a38655a76d3b1c334677d9e9258973b1993f61187f589666e946029a3

Contents?: true

Size: 1.97 KB

Versions: 1

Compression:

Stored size: 1.97 KB

Contents

# Version
require "linkshare_api/version"

# Resources
require File.expand_path("../linkshare_api/link_generator", __FILE__)
require File.expand_path("../linkshare_api/product_search", __FILE__)
require File.expand_path("../linkshare_api/coupon_web_service", __FILE__)
require File.expand_path("../linkshare_api/response", __FILE__)

# Errors
require File.expand_path("../linkshare_api/errors/error", __FILE__)
require File.expand_path("../linkshare_api/errors/authentication_error", __FILE__)
require File.expand_path("../linkshare_api/errors/connection_error", __FILE__)
require File.expand_path("../linkshare_api/errors/invalid_request_error", __FILE__)

module LinkshareAPI
  WEB_SERVICE_URIS = {
    link_generator: "http://getdeeplink.linksynergy.com/createcustomlink.shtml",
    product_search: "http://productsearch.linksynergy.com/productsearch",
    coupon_web_service: "http://couponfeed.linksynergy.com/coupon"
  }

  PARSE_RESULT = {
    link_generator: "item",
    product_search: "item",
    coupon_web_service: "link"
  }

  RESULT = {
    product_search: "result",
    coupon_web_service: "couponfeed"
  }

  PAGE_NUMBER = {
    product_search: "PageNumber",
    coupon_web_service: "PageNumberRequested"
  }

  @api_timeout  = 30

  class << self
    attr_accessor :token
    attr_reader   :api_timeout
  end

  def self.api_timeout=(timeout)
    raise ArgumentError, "Timeout must be a Fixnum; got #{timeout.class} instead" unless timeout.is_a? Fixnum
    raise ArgumentError, "Timeout must be > 0; got #{timeout} instead" unless timeout > 0
    @api_timeout = timeout
  end

  def self.link_generator(mid, murl)
    link_generator = LinkshareAPI::LinkGenerator.new
    link_generator.build(mid, murl)
  end

  def self.product_search(options = {})
    product_search = LinkshareAPI::ProductSearch.new
    product_search.query(options)
  end

  def self.coupon_web_service(options = {})
    coupon_web_service = LinkshareAPI::CouponWebService.new
    coupon_web_service.query(options)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
linkshare_api-0.2.0 lib/linkshare_api.rb