Sha256: 5d58970158117d064994278c466daea6ba679d9163a5c19c6aac2eafcc2cd111
Contents?: true
Size: 1.31 KB
Versions: 2
Compression:
Stored size: 1.31 KB
Contents
module Shoppr class Client include HTTParty format :xml attr_reader :api_key, :tracking_id, :sandboxed, :api_version # Get your api_key found here http://developer.shopping.com/docs/Getting_Started def initialize(sandboxed=false) @api_key ||= Shoppr.api_key @tracking_id ||= Shoppr.tracking_id @sandboxed = sandboxed base_uri = (self.sandboxed? ? 'sandbox.api.shopping.com/publisher/3.0/rest' : 'publisher.usb.api.shopping.com/publisher/3.0/rest') self.class.base_uri base_uri end def sandboxed? !!@sandboxed end def api_version self.class.parser Proc.new {|response| GenericResponse.from_xml(response)} @api_version ||= self.class.get('/').server_detail.api_version end def search(options={}) self.class.parser Proc.new {|response| GeneralSearchResponse.from_xml(response)} self.class.get('/GeneralSearch', :query => default_options.merge(prep_query_options(options))) end private def default_options {:apiKey => self.api_key, :trackingId => self.tracking_id} end def prep_query_options(options) opts = {} options.each do |key, value| opts[key.to_s.camelize(:lower)] = value end opts end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
shoppr-0.1.1 | lib/shoppr/client.rb |
shoppr-0.1.0 | lib/shoppr/client.rb |