viglink-api 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ spec/cassettes
16
+ test/tmp
17
+ test/version_tmp
18
+ tmp
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --color
2
+ --format documentation
3
+ --tty
data/Gemfile ADDED
@@ -0,0 +1,10 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in viglink-api.gemspec
4
+ gemspec
5
+
6
+ group :development, :test do
7
+ gem 'guard'
8
+ gem 'guard-rspec'
9
+ gem 'rb-fsevent'
10
+ end
@@ -0,0 +1,5 @@
1
+ guard 'rspec' do
2
+ watch(%r{^spec/.+_spec\.rb$})
3
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
4
+ watch('spec/spec_helper.rb') { "spec" }
5
+ end
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2013 Clayton Liggitt
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Clayton Liggitt
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,119 @@
1
+ # Viglink
2
+
3
+ This gem is a wrapper for the [Viglink Catalog API](http://support.viglink.com/entries/22326692-VigLink-Catalog-API-Documentation). This gem contains module methods for each API endpoint, as well as an additional subset for the CUID revenue API.
4
+
5
+ ## Installation
6
+
7
+ Command line installation:
8
+
9
+ gem install viglink-api
10
+
11
+ Or add this line to your application's Gemfile:
12
+
13
+ gem 'viglink-api'
14
+
15
+ And then execute bundler:
16
+
17
+ bundle
18
+
19
+ ---
20
+
21
+ ## Usage
22
+
23
+ #### Command Line
24
+
25
+ To use on the command line, simply require the file and create a new client
26
+
27
+ ```ruby
28
+ require 'viglink_api'
29
+ viglink = ViglinkApi::Client.new({:api_key => ENV['VIGLINK_API_KEY']})
30
+ ```
31
+
32
+ #### Rails
33
+
34
+ Include the `viglink-api` gem in your Gemfile and bundle. The module can be configured by creating a config file:
35
+
36
+ `config/initializers/viglink.rb`
37
+
38
+ ```ruby
39
+ ViglinkApi.configure do |config|
40
+ config.api_key = "your_api_key"
41
+ end
42
+ ```
43
+
44
+ Please see below for more configuration options.
45
+
46
+ ### Search Methods
47
+
48
+ Please refer to the [Viglink Catalog API documentation](http://support.viglink.com/entries/22326692-VigLink-Catalog-API-Documentation) for details on additional fields that can be included. Each method can accept a hash of values to pass through to the search. *Key is included by default.*
49
+
50
+ - `find_products`
51
+ - `find_merchants`
52
+ - `find_merchant_types`
53
+ - `find_deals`
54
+ - `find_deal_types`
55
+ - `find_countries`
56
+
57
+
58
+ ### Configuration Options
59
+
60
+ - `api_url` sets the API base url. Default: http://catalog.viglink.com
61
+ - `api_key` should be set to your campaign API key. Default: nil
62
+ - `api_key` can be set to your campaign API secret key. Default: nil
63
+ - `api_full_response` Determines if the searches return the full response hashes or only the segment of the response related to the request. Default: true
64
+ - `api_cuid_url` sets the CUID API base url. Default: https://www.viglink.com/service/v1/cuidRevenue
65
+
66
+
67
+ -----
68
+
69
+ ## CUID Payment API
70
+
71
+ Please refer to the [Viglink CUID API documentation](http://support.viglink.com/entries/22235658-viglink-developer-guide) (the section on "Advanced Revenue Tracking") for additional information.
72
+
73
+ ### Usage
74
+
75
+ The defaults for this segment of the API default to the general ViglinkApi configuration
76
+
77
+ ```ruby
78
+ viglink = ViglinkApi::Purchases.new
79
+ ```
80
+
81
+ Or for a one-off call independent from the ViglinkApi configuration (please see below for more configuration options):
82
+
83
+ ```ruby
84
+ viglink = ViglinkApi::Purchases.new({:api_secret => "your_secret_key", :period => "week"})
85
+ ```
86
+
87
+ ### Methods
88
+
89
+ - `find_purchases` performs a search and accepts an options hash with the following keys:
90
+ - `last_date` sets the start date for search. Format: YYYY/MM/DD ("%Y/%m/%d"). Default: 1 day ago.
91
+ - `period` determines the search period. Options: day, week, month. Default: day
92
+
93
+ ### Options
94
+
95
+ - `api_secret` should be set to your Viglink API secret key. Default: nil
96
+ - `api_cuid_url` = options[:api_cuid_url] || ViglinkApi.api_cuid_url
97
+ - `last_date` sets the start date for search. Format: YYYY/MM/DD ("%Y/%m/%d"). Default: 1 day ago.
98
+ - `period` determines the search period. Options: day, week, month. Default: day
99
+
100
+
101
+ -----
102
+
103
+ ## Contributing
104
+
105
+ Contributions welcome!
106
+
107
+ - We need more tests, and the existing ones need updating
108
+ - More documentation and code commenting
109
+ - Debugging and exception handling
110
+ - Features!
111
+
112
+ In traditional GitHub style:
113
+
114
+ 1. Fork it
115
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
116
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
117
+ 4. Push to the branch (`git push origin my-new-feature`)
118
+ 5. Create new Pull Request
119
+
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
3
+ require "rspec/core/rake_task"
4
+
5
+ RSpec::Core::RakeTask.new(:spec)
6
+
7
+ task default: :spec
@@ -0,0 +1,129 @@
1
+ 
2
+ <!DOCTYPE html>
3
+ <html>
4
+ <head>
5
+ <title>VigLink API documentation</title>
6
+ <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
7
+ <style type="text/css">
8
+ #nav {float:left;width:200px;}
9
+ #nav a {display:block;padding:5px;}
10
+ #content {margin-left:220px;}
11
+ table {border-collapse:collapse;width:100%;}
12
+ table th {background:#666;color:#fff;text-align:left;}
13
+ table th, table td {padding:2px 5px;}
14
+ tr:nth-child(odd) { background: #cfcfcf; }
15
+ .xpath {width:300px;}
16
+ </style>
17
+ </head>
18
+ <body>
19
+ <div id="api">
20
+ <div id="nav"></div>
21
+ <div id="content"></div>
22
+ </div>
23
+ <script>
24
+ var api = {"title":"VigLink API","description":"Product comparison API.","base_url":"http://catalog.viglink.com/vigcatalog/","guides":[{"title":"Getting started","description":"To get started with the API you will need to be assigned an API \"key\". Once you have this \"key\" you can begin making API calls."},{"title":"How do you get information from the API?","description":"API calls are implemented as a RESTful API. XML response formats are currently provided. Most calls to the API are made with an HTTP GET (look it up). To make an API call you will need to have your API \"key\". See specific API calls to find the list of allowed formats, HTTP methods, required parameters, and optional parameters."},{"title":"API fair usage limit","description":"THE API provides for fair usage based on click-thru rate and transaction conversion rate performance on server requests. Too many server calls with very few transactions will result in the API not working for you. A server request is each time our servers are called with your unique API \"key\". The API may return many results on a query, but it is counted as one call. Pagination, filtering, and clicks are counted as additional server calls. It is recommended that you blacklist bots from your websites so as to maintain good click-thru and conversion rate."},{"title":"What can you do with the API?","description":"The API was created and designed for marketers who are either developers or have development resources to work with. Regretfully we can not help you with your custom PHP, ASP, Rails, or teach you how to parse XML.\r\n\r\nWith the API you can create anything from a dynamic super mall to a range of niche coupon sites, and have complete control over the code including HTML and the content calls to populate your websites."},{"title":"Products vs. Offers","description":"To better use the API, you need to understand a core concept around shopping comparison.\r\n\r\nA product is an item made by a manufacturer. This can be an ipod, a curling iron, a song, a surfboard, etc. You buy a product from one or more merchants.\r\n\r\nAn offer is a product being sold by a specific merchant. It has a specific price being offered by the merchant for the product, and a specific URL to link to the merchant page offering the product. An example of this would be an iPod is a product manufactured by Apple, but offered for sale from Buy.com, Newegg, pcRush.com, etc."},{"title":"Standard response structure","description":"All responses have a standardized structure that adds semantic meaning to the information being returned.\r\n\r\nA response is now comprised of the following container nodes:\r\n\r\n1. <response> - All responses will be contained within a top level response node. This may contain attributes relating to the success or failure of the query.\r\n\r\n2. <parameters> - The parameters node is used to list all parameters that were used to build up the response information. This can be used for troubleshooting problems, as well as rebuilding links by knowing how you got to the information you are currently viewing.\r\n\r\n3. <results> - This node contains the primary information found using the parameters that were passed in to make the query. The results can contain different kinds of information such as products, deals, merchants, etc. The type of information returned in the results is based on the resource being requested in the URL. You will find examples of this in the different API documentation specific to that resource.\r\n\r\n4. <resources> - A resource is an entity you wish to get information about. In the context of the API we use this node to provide additional information about items contained in the results node. We do this to minimize the amount of information being duplicated in a response, while still providing all the information you need to build something on your end. An example of this is a merchant resource node being returned for a products call. If you do a product search looking for 'ipods' instead of re-listing all merchant information on every single product node, we provide a separate merchant node in the resources, and each product node provides a reference id to get the merchant for information.\r\n\r\n5. <filters> - Filters show you options available to you for further refining the current search. These filters may be ranges for prices or percent offs, or maybe a reference to resources you could filter on."},{"title":"Parameter types","description":"There are distinct types of parameters you can use in the API. The parameter type indicates a certain type of behavior for that parameter. You do not need to pass the parameter type, it is only used to indicate to you how a parameter can be used.","examples":[{"title":"item","description":"Accepts individual values. Multiple delimited values are not allowed."},{"title":"range","description":"Accepts a single value for matching exactly, or min/max values delimited with a dash '-' used for searching across a range of values. For example price=50-100, or percent_off=25."},{"title":"selection","description":"Accepts a single or multiple values. Multiple values are delimited with a comma ','. For example product=1 OR product=1,2,3"}]},{"title":"Parameter kinds","description":"Parameter kinds describe how a parameter is going to be used within the search itself. Some are used to authenticate your account, others used to sort the results. You do not need to pass the parameter kind, it is only used to indicate how a parameter will be used.","examples":[{"title":"account","description":"This is a parameter tying the results to your specific account"},{"title":"control","description":"Controls fundamental types of additional resources being returned in a response."},{"title":"filter","description":"A parameter used to constrain the results that will be searched within."},{"title":"pagination","description":"Parameters specifically altering number of results returned. Example: page=1&results_per_page=100"},{"title":"query","description":"A parameter used for any search comparison looking at textual information about products, categories, merchants, etc."},{"title":"session","description":"Stores data about the previous API call in order to provide consistent browsing mechanisms."},{"title":"sort","description":"Determines sort ordering for specific results returned."},{"title":"value","description":"This is a value being passed in to update a record within an account."},{"title":"view","description":"Alters attributes or nodes returned in a response."}]},{"title":"Attribute types","description":"Attribute types are used to describe an attribute being returned for a specific result. It is an indication to you what type of data the attribute contains.","examples":[{"title":"count","description":"A count of the number of results."},{"title":"display","description":"A displayable value for a result."},{"title":"image","description":"An image URL."},{"title":"price","description":"A price related to a result."},{"title":"primary_key","description":"This is a unique primary identifier for a result."},{"title":"redirect_url","description":"A URL that will redirect to a final merchant page, after attaching all necessary tracking information into the URL."},{"title":"resource","description":"This identifies an attribute that is an id for an associated resource that is found within the resources section of the response."},{"title":"percentage","description":"A displayable percentage value."},{"title":"direct_url","description":"A direct URL to a merchant page that will not include any tracking information."}]},{"title":"Resources","description":"A resource at it's simplest is an entity you wish to get information about. In the context of the API we use this concept to return information on many different things. The following list of resources describe the common types of information you will encounter in API responses.","examples":[{"title":"Attribute","description":"An attribute for a product. Examples such as color, screen resolution, size, etc."},{"title":"Attribute Group","description":"A group of attributes within a product specification."},{"title":"Brand","description":"The brand or manufacturer for a product. This is not available to be searched directly, but appears in product results."},{"title":"Category","description":"Categories are used to classify similar products."},{"title":"Country","description":"Country a merchant operates within. This primarily influences the type of currency prices are provided in. This only exists as nodes and filters in other calls."},{"title":"Deal","description":"A deal provided through an affiliate network for a specific merchant. Usually expressed as a percent off, dollar off, or some other special discount for a specific period of time."},{"title":"Deal type","description":"A simple classification system for deals. These are essentially custom categories for deals."},{"title":"Filter","description":"A filter is a resource/attribute or other condition that another resource can be filtered by."},{"title":"Merchant","description":"A merchant or store that provides offers for products."},{"title":"Merchant type","description":"A classification of a merchant, not necessarily it's products or offers."},{"title":"Offer","description":"This represents an instance of a product being sold by a specific merchant."},{"title":"Product","description":"A product is a physical good sold by one or more merchants."},{"title":"Specification","description":"A specification contains attribute groups, and attributes describing the product in more detail. Usually these correspond to the categories the product belongs to."}]},{"title":"A note about XML node attributes","description":"We try to only bring back the information you need. If an attribute or node is empty, then it usually is not returned. Don't always count on an attribute or node on being there. If an attribute is guaranteed to always be there, we will mark it as 'required'."},{"title":"About sessions","description":"The \"session\" parameter is basically a container for us to manage information about previous states of requests. This information is used to better populate the different filters and resources available in the current request, allowing for you to build better navigation for any final user of your information.\r\n\r\nFor example, by passing the session parameter value we give to you, a subsequent request would know the price ranges that were available on the previous call, and would be able to inject those values back into the results for you to provide a better browsing experience for your user."}],"calls":[{"title":"Find products","description":"Product calls are used to get all information related to products, and the specific merchant offers for those products. One thing to note is that only offers will have links associated with them, the product itself will not have a URL.","format":"xml","required_parameters":[{"title":"key","description":"Your API account key.","parameter_type":"","parameter_kind":"account","allowed_values":"","default_value":"","required":true}],"optional_parameters":[{"title":"category","description":"Filter products by a specific category ID. This can only be passed in conjunction with a keyword parameter.","parameter_type":"item","parameter_kind":"filter","allowed_values":"","default_value":"","required":false},{"title":"include_discounts","description":"This will force the response to return the top discounted offer for each product as part of the results.","parameter_type":"","parameter_kind":"control","allowed_values":"","default_value":"","required":false},{"title":"keyword","description":"A keyword or phrase you want to find in the product name or description","parameter_type":"","parameter_kind":"query","allowed_values":"","default_value":"","required":false},{"title":"keyword_description","description":"A keyword or phrase you want to find specifically in the product description.","parameter_type":"","parameter_kind":"query","allowed_values":"","default_value":"","required":false},{"title":"keyword_ean","description":"A term you want to match against a product's EAN.","parameter_type":"","parameter_kind":"query","allowed_values":"","default_value":"","required":false},{"title":"keyword_isbn","description":"A term you want to match against a product's ISBN","parameter_type":"","parameter_kind":"query","allowed_values":"","default_value":"","required":false},{"title":"keyword_mpn","description":"A term you want to match against a product's MPN.","parameter_type":"","parameter_kind":"query","allowed_values":"","default_value":"","required":false},{"title":"keyword_name","description":"A keyword or phrase you want to find specifically in the product name.","parameter_type":"","parameter_kind":"query","allowed_values":"","default_value":"","required":false},{"title":"keyword_person","description":"A term you want to match against a product's author or artist.","parameter_type":"","parameter_kind":"query","allowed_values":"","default_value":"","required":false},{"title":"keyword_upc","description":"A term you want to match against a product's UPC.","parameter_type":"","parameter_kind":"query","allowed_values":"","default_value":"","required":false},{"title":"keyword_isbn","description":"A term you want to match against a product's ISBN.","parameter_type":"","parameter_kind":"query","allowed_values":"","default_value":"","required":false},{"title":"merchant","description":"The merchant ID of the merchant a product's offers should belong to.","parameter_type":"selection","parameter_kind":"filter","allowed_values":"","default_value":"","required":false},{"title":"merchant_type","description":"The merchant type ID of the merchant a product's offers should belong to.","parameter_type":"selection","parameter_kind":"filter","allowed_values":"","default_value":"","required":false},{"title":"page","description":"The page number of results to return.","parameter_type":"item","parameter_kind":"pagination","allowed_values":"1-100","default_value":"1","required":false},{"title":"percent_off","description":"The exact percent off you want the offer merchant prices vs. retail prices. This is an example of requesting products with offers with at least a 5% off price to a maximum of 10% off: perent_off=5-10","parameter_type":"range","parameter_kind":"filter","allowed_values":"","default_value":"","required":false},{"title":"percent_off_max","description":"The maximum percent off you want the offer merchant prices vs. retail prices","parameter_type":"range","parameter_kind":"filter","allowed_values":"","default_value":"","required":false},{"title":"percent_off_min","description":"The minimum percent off you want the offer merchant prices vs. retail prices","parameter_type":"range","parameter_kind":"filter","allowed_values":"","default_value":"","required":false},{"title":"price","description":"The exact price you want the offer merchant prices. This is an example of requesting products with offers with at least a $5 price to a maximum of $10 off: price=5-10","parameter_type":"range","parameter_kind":"filter","allowed_values":"","default_value":"","required":false},{"title":"price_max","description":"\tThe maximum price you want the offer merchant prices.","parameter_type":"range","parameter_kind":"filter","allowed_values":"","default_value":"","required":false},{"title":"price_min","description":"The minimum price you want the offer merchant prices.","parameter_type":"range","parameter_kind":"filter","allowed_values":"","default_value":"","required":false},{"title":"product","description":"\tThe product ID of the exact product you want returned. Could be a comma delimited list of multiple product IDs.","parameter_type":"selection","parameter_kind":"","allowed_values":"","default_value":"","required":false},{"title":"results_per_page","description":"The number of products to return in every response.","parameter_type":"item","parameter_kind":"pagination","allowed_values":"1-100","default_value":"20","required":false},{"title":"session","description":"Zipped info used to build more relevant filter values in the response in order to get back to previous filtered states. You do NOT to generate session value, it is provided in the parameters block. Pass it forward for any additional calls you make.","parameter_type":"","parameter_kind":"session","allowed_values":"","default_value":"","required":false},{"title":"end_on_min","description":"The minimum end on date for a deal.","parameter_type":"range","parameter_kind":"filter","allowed_values":"","default_value":"","required":false}],"response_nodes":[{"response_section":"resources","xpath":"/response/resources/categories/matches/category","resource":"Category","attribute":"id","kind":"primary_key","data_type":"integer","description":"The unique identifier for the category. This acts as a primary key that can be used to reference the category.","required":true},{"response_section":"resources","xpath":"/response/resources/categories/matches/category","resource":"Category","attribute":"leaf","kind":"display","data_type":"boolean","description":"Indicates whether or not the category is a leaf in the category tree and does not have any child categories.","required":false},{"response_section":"resources","xpath":"/response/resources/categories/matches/category","resource":"Category","attribute":"name","kind":"display","data_type":"string","description":"The display name of the category.","required":true},{"response_section":"resources","xpath":"/response/resources/categories/matches/category","resource":"Category","attribute":"count","kind":"count","data_type":"integer","description":"A contextual count of how many resources belong to a category that match any query parameters.","required":false},{"response_section":"resources","xpath":"/response/resources/deal_types/deal_type","resource":"Deal type","attribute":"id","kind":"primary_key","data_type":"integer","description":"The unique identifier for a deal type. This acts as a primary key that can be used to reference the deal type.","required":true},{"response_section":"resources","xpath":"/response/resources/deal_types/deal_type","resource":"Deal type","attribute":"name","kind":"display","data_type":"string","description":"The display name of the deal type.","required":true},{"response_section":"resources","xpath":"/response/resources/deal_types/deal_type","resource":"Deal type","attribute":"deal_count","kind":"count","data_type":"integer","description":"A count of deals that belong to the deal type.","required":false},{"response_section":"resources","xpath":"/response/resources/merchants/merchant","resource":"Merchant","attribute":"category","kind":"resource","data_type":"integer","description":"A category ID for the category the merchant belongs to.","required":false},{"response_section":"resources","xpath":"/response/resources/merchants/merchant","resource":"Merchant","attribute":"country","kind":"resource","data_type":"integer","description":"A country ID for the country the merchant belongs to.","required":false},{"response_section":"resources","xpath":"/response/resources/merchants/merchant","resource":"Merchant","attribute":"deal_count","kind":"count","data_type":"integer","description":"The number of deals available from the merchant.","required":false},{"response_section":"resources","xpath":"/response/resources/merchants/merchant","resource":"Merchant","attribute":"id","kind":"primary_key","data_type":"integer","description":"The unique identifier for the merchant within the API. This acts as a primary key that can be used to reference the merchant.","required":true},{"response_section":"resources","xpath":"/response/resources/merchants/merchant","resource":"Merchant","attribute":"logo_url","kind":"image","data_type":"string","description":"The URL for a merchant logo. Merchant logos default to a size of 88x31.","required":false},{"response_section":"resources","xpath":"/response/resources/merchants/merchant","resource":"Merchant","attribute":"merchant_type","kind":"resource","data_type":"integer","description":"A merchant type ID for the merchant type the merchant belongs to.","required":false},{"response_section":"resources","xpath":"/response/resources/merchants/merchant","resource":"Merchant","attribute":"name","kind":"display","data_type":"string","description":"The name of the merchant.","required":true},{"response_section":"resources","xpath":"/response/resources/merchants/merchant","resource":"Merchant","attribute":"product_count","kind":"count","data_type":"integer","description":"The number of products offered by the merchant.","required":false},{"response_section":"resources","xpath":"/response/resources/merchants/merchant","resource":"Merchant","attribute":"site_url","kind":"direct_url","data_type":"string","description":"The direct URL to the merchant's website. This URL does NOT have any tracking information in it.","required":false},{"response_section":"resources","xpath":"/response/resources/merchants/merchant","resource":"Merchant","attribute":"url","kind":"redirect_url","data_type":"string","description":"The redirect URL that will pass along tracking information on a click.","required":false},{"response_section":"resources","xpath":"/response/resources/merchants/merchant","resource":"Merchant","attribute":"count","kind":"count","data_type":"integer","description":"A contextual count of offers or deals matching any query parameters.","required":false},{"response_section":"results","xpath":"/response/results/deals/deal","resource":"Deal","attribute":"code","kind":"display","data_type":"string","description":"If a deal happens to be a coupon, this is the coupon code for it.","required":false},{"response_section":"results","xpath":"/response/results/deals/deal","resource":"Deal","attribute":"deal_type","kind":"resource","data_type":"integer","description":"This is the deal_type ID of the deal type the deal belongs to. it is possible for this to be a comma delimited list of deal type ids, if the deal belongs to more than one.","required":true},{"response_section":"results","xpath":"/response/results/deals/deal","resource":"Deal","attribute":"description","kind":"display","data_type":"string","description":"A merchant provided description of the deal.","required":false},{"response_section":"results","xpath":"/response/results/deals/deal","resource":"Deal","attribute":"end_on","kind":"display","data_type":"date","description":"The date the deal expires on.","required":false},{"response_section":"results","xpath":"/response/results/deals/deal","resource":"Deal","attribute":"id","kind":"primary_key","data_type":"integer","description":"The unique identifier for the deal in API calls.","required":true},{"response_section":"results","xpath":"/response/results/deals/deal","resource":"Deal","attribute":"image_url","kind":"image","data_type":"string","description":"The URL to an image for the deal.","required":false},{"response_section":"results","xpath":"/response/results/deals/deal","resource":"Deal","attribute":"merchant","kind":"resource","data_type":"integer","description":"The merchant ID of the merchant the deal belongs to.","required":true},{"response_section":"results","xpath":"/response/results/deals/deal","resource":"Deal","attribute":"name","kind":"display","data_type":"string","description":"The name of the deal.","required":true},{"response_section":"results","xpath":"/response/results/deals/deal","resource":"Deal","attribute":"restrictions","kind":"display","data_type":"string","description":"A description of any related restrictions on the deal that may limit its ability to be redeemed.","required":false},{"response_section":"results","xpath":"/response/results/deals/deal","resource":"Deal","attribute":"site_wide","kind":"display","data_type":"boolean","description":"Indicates whether or not the deal is applicable across a merchant's entire website, or limited to a specific product or category.","required":false},{"response_section":"results","xpath":"/response/results/deals/deal","resource":"Deal","attribute":"start_on","kind":"display","data_type":"date","description":"The starting date a deal is valid on.","required":false},{"response_section":"results","xpath":"/response/results/deals/deal","resource":"Deal","attribute":"url","kind":"redirect_url","data_type":"string","description":"A redirect URL that links to the deal landing page after passing along any tracking information for you.","required":true},{"response_section":"results","xpath":"/response/results/products/product/attributes/attribute","resource":"Attribute","attribute":"name","kind":"display","data_type":"string","description":"The name describing what type of attribute this is for the product. Examples of this are MPN, UPC, ISBN, etc.","required":true},{"response_section":"results","xpath":"/response/results/products/product/attributes/attribute","resource":"Attribute","attribute":"value","kind":"display","data_type":"string","description":"The actual value of the attribute for the product.","required":true},{"response_section":"results","xpath":"/response/results/products/product/offers/offer","resource":"Offer","attribute":"currency_iso","kind":"display","data_type":"string","description":"The currency ISO code for the offer prices.","required":false},{"response_section":"results","xpath":"/response/results/products/product/offers/offer","resource":"Offer","attribute":"currency_symbol","kind":"display","data_type":"string","description":"The HTML entity for the currency symbol of the offer.","required":false},{"response_section":"results","xpath":"/response/results/products/product/offers/offer","resource":"Offer","attribute":"description","kind":"display","data_type":"string","description":"The merchant provided description of the product offer.","required":false},{"response_section":"results","xpath":"/response/results/products/product/offers/offer","resource":"Offer","attribute":"id","kind":"primary_key","data_type":"integer","description":"The is the unique identifier for the merchant offer in API calls.","required":true},{"response_section":"results","xpath":"/response/results/products/product/offers/offer","resource":"Offer","attribute":"image_url_large","kind":"image","data_type":"string","description":"The merchant provided large sized image URL.","required":false},{"response_section":"results","xpath":"/response/results/products/product/offers/offer","resource":"Offer","attribute":"image_url_medium","kind":"image","data_type":"string","description":"The merchant provided medium sized image URL.","required":false},{"response_section":"results","xpath":"/response/results/products/product/offers/offer","resource":"Offer","attribute":"image_url_small","kind":"image","data_type":"string","description":"The merchant provided small sized image URL.","required":false},{"response_section":"results","xpath":"/response/results/products/product/offers/offer","resource":"Offer","attribute":"merchant","kind":"resource","data_type":"integer","description":"The merchant ID of the merchant the offer belongs to.","required":false},{"response_section":"results","xpath":"/response/results/products/product/offers/offer","resource":"Offer","attribute":"name","kind":"display","data_type":"string","description":"The merchant provided name of the product offer.","required":true},{"response_section":"results","xpath":"/response/results/products/product/offers/offer","resource":"Offer","attribute":"percent_off","kind":"percentage","data_type":"float","description":"The calculated percent off from the merchant provided price, and the merchant provided retail price.","required":false},{"response_section":"results","xpath":"/response/results/products/product/offers/offer","resource":"Offer","attribute":"price_merchant","kind":"price","data_type":"float","description":"The merchant provided price they are selling the product offer for.","required":false},{"response_section":"results","xpath":"/response/results/products/product/offers/offer","resource":"Offer","attribute":"price_retail","kind":"price","data_type":"float","description":"The merchant provided retail price to compare against the price they are offering the product at.","required":false},{"response_section":"results","xpath":"/response/results/products/product/offers/offer","resource":"Offer","attribute":"url","kind":"redirect_url","data_type":"string","description":"A redirect URL that will end at the merchant site after attaching necessary tracking information.","required":true},{"response_section":"results","xpath":"/response/results/products/product","resource":"Product","attribute":"brand","kind":"resource","data_type":"integer","description":"The id of the brand a product belongs to.","required":false},{"response_section":"results","xpath":"/response/results/products/product","resource":"Product","attribute":"category","kind":"resource","data_type":"integer","description":"The id of the category a product belongs to.","required":false},{"response_section":"results","xpath":"/response/results/products/product","resource":"Product","attribute":"description","kind":"display","data_type":"string","description":"A description of the product","required":false},{"response_section":"results","xpath":"/response/results/products/product","resource":"Product","attribute":"id","kind":"primary_key","data_type":"integer","description":"A unique identifier of the product that can be used in API calls.","required":true},{"response_section":"results","xpath":"/response/results/products/product","resource":"Product","attribute":"image_url_large","kind":"image","data_type":"string","description":"A URL for a large sized image of the product.","required":false},{"response_section":"results","xpath":"/response/results/products/product","resource":"Product","attribute":"image_url_medium","kind":"image","data_type":"string","description":"A URL for a medium sized image of the product.","required":false},{"response_section":"results","xpath":"/response/results/products/product","resource":"Product","attribute":"image_url_small","kind":"image","data_type":"string","description":"A URL for a small sized image of the product.","required":false},{"response_section":"results","xpath":"/response/results/products/product","resource":"Product","attribute":"name","kind":"display","data_type":"string","description":"The name of the product.","required":true},{"response_section":"results","xpath":"/response/results/products/product","resource":"Product","attribute":"offer_count","kind":"count","data_type":"integer","description":"A count of the number of merchant offers available for the product.","required":false},{"response_section":"results","xpath":"/response/results/products/product","resource":"Product","attribute":"price_max","kind":"price","data_type":"float","description":"The maximum price of all merchant offers for the product.","required":false},{"response_section":"results","xpath":"/response/results/products/product","resource":"Product","attribute":"price_min","kind":"price","data_type":"float","description":"The minimum price of all merchant offers for the product.","required":false}],"request_url":"http://catalog.viglink.com/vigcatalog/products.xml"},{"title":"Find coupons and deals","description":"Find coupons and deals","format":"xml","required_parameters":[{"title":"key","description":"Your API account key.","parameter_type":"","parameter_kind":"account","allowed_values":"","default_value":"","required":true}],"optional_parameters":[{"title":"end_on","description":"The end on date a deal is still valid for. Pass in a single date for an exact match, or pass in a range of dates delimited with a dash '-'.","parameter_type":"range","parameter_kind":"filter","allowed_values":"","default_value":"","required":false},{"title":"end_on_max","description":"The maximum end on date for a deal.","parameter_type":"range","parameter_kind":"filter","allowed_values":"","default_value":"","required":false},{"title":"deal_type","description":"The deal type ID a deal belongs to.","parameter_type":"selection","parameter_kind":"filter","allowed_values":"","default_value":"","required":false},{"title":"keyword","description":"A term or phrase you want to find in the deal name or description.","parameter_type":"","parameter_kind":"query","allowed_values":"","default_value":"","required":false},{"title":"keyword_description","description":"A term or phrase you want to find in the deal description.","parameter_type":"","parameter_kind":"query","allowed_values":"","default_value":"","required":false},{"title":"keyword_name","description":"A term or phrase you want to find in the deal name.","parameter_type":"","parameter_kind":"query","allowed_values":"","default_value":"","required":false},{"title":"merchant","description":"The merchant ID of the merchant a deal belongs to.","parameter_type":"selection","parameter_kind":"filter","allowed_values":"","default_value":"","required":false},{"title":"merchant_type","description":"The merchant type ID that a deal's merchant belongs to.","parameter_type":"selection","parameter_kind":"filter","allowed_values":"","default_value":"","required":false},{"title":"page","description":"The page number of the results you want returned.","parameter_type":"item","parameter_kind":"pagination","allowed_values":"1-100","default_value":"1","required":false},{"title":"results_per_page","description":"The number of deals to return in every response.","parameter_type":"item","parameter_kind":"pagination","allowed_values":"1-100","default_value":"20","required":false},{"title":"session","description":"Zipped info used to build more relevant filter values in the response in order to get back to previous filtered states. You do NOT to generate session value, it is provided in the parameters block. Pass it forward for any additional calls you make.","parameter_type":"","parameter_kind":"session","allowed_values":"","default_value":"","required":false},{"title":"site_wide","description":"Indicates whether or not a deal applies site wide on a merchant's site, as opposed to being for a specific product or specific category within the merchant's site.","parameter_type":"item","parameter_kind":"filter","allowed_values":"all,yes,no","default_value":"all","required":false},{"title":"sort_deal","description":"The sort order the deals are returned in","parameter_type":"","parameter_kind":"sort","allowed_values":"relevance, name_asc, name_desc, start_on_asc, start_on_desc, end_on_asc, end_on_desc, merchant_name_asc, merchant_name_desc","default_value":"relevance","required":false},{"title":"start_on","description":"The start on date a deal is valid for. Pass in a single date for an exact match, or pass in a range of dates delimited with a dash '-'.","parameter_type":"range","parameter_kind":"filter","allowed_values":"","default_value":"","required":false},{"title":"start_on_max","description":"The maximum start on date for a deal.","parameter_type":"range","parameter_kind":"filter","allowed_values":"","default_value":"","required":false},{"title":"start_on_min","description":"The minimum start on date for a deal.","parameter_type":"range","parameter_kind":"filter","allowed_values":"","default_value":"","required":false}],"response_nodes":[{"response_section":"resources","xpath":"/response/resources/deal_types/deal_type","resource":"Deal type","attribute":"id","kind":"primary_key","data_type":"integer","description":"The unique identifier for a deal type. This acts as a primary key that can be used to reference the deal type.","required":true},{"response_section":"resources","xpath":"/response/resources/deal_types/deal_type","resource":"Deal type","attribute":"name","kind":"display","data_type":"string","description":"The display name of the deal type.","required":true},{"response_section":"resources","xpath":"/response/resources/deal_types/deal_type","resource":"Deal type","attribute":"deal_count","kind":"count","data_type":"integer","description":"A count of deals that belong to the deal type.","required":false},{"response_section":"resources","xpath":"/response/resources/countries/country","resource":"Country","attribute":"currency","kind":"display","data_type":"string","description":"The encoded currency symbol for a country.","required":false},{"response_section":"resources","xpath":"/response/resources/countries/country","resource":"Country","attribute":"id","kind":"primary_key","data_type":"integer","description":"The unique identifier for a country. This acts as a primary key that can be used to reference the country.","required":true},{"response_section":"resources","xpath":"/response/resources/countries/country","resource":"Country","attribute":"iso","kind":"display","data_type":"string","description":"The two character ISO code for the country.","required":false},{"response_section":"resources","xpath":"/response/resources/countries/country","resource":"Country","attribute":"iso3","kind":"display","data_type":"string","description":"The three character ISO3 code for the country.","required":false},{"response_section":"resources","xpath":"/response/resources/countries/country","resource":"Country","attribute":"merchant_count","kind":"count","data_type":"integer","description":"The number of merchants that belong to a country.","required":false},{"response_section":"resources","xpath":"/response/resources/countries/country","resource":"Country","attribute":"name","kind":"display","data_type":"string","description":"The display name of a country.","required":true},{"response_section":"resources","xpath":"/response/resources/merchants/merchant","resource":"Merchant","attribute":"category","kind":"resource","data_type":"integer","description":"A category ID for the category the merchant belongs to.","required":false},{"response_section":"resources","xpath":"/response/resources/merchants/merchant","resource":"Merchant","attribute":"country","kind":"resource","data_type":"integer","description":"A country ID for the country the merchant belongs to.","required":false},{"response_section":"resources","xpath":"/response/resources/merchants/merchant","resource":"Merchant","attribute":"deal_count","kind":"count","data_type":"integer","description":"The number of deals available from the merchant.","required":false},{"response_section":"resources","xpath":"/response/resources/merchants/merchant","resource":"Merchant","attribute":"id","kind":"primary_key","data_type":"integer","description":"The unique identifier for the merchant within the API. This acts as a primary key that can be used to reference the merchant.","required":true},{"response_section":"resources","xpath":"/response/resources/merchants/merchant","resource":"Merchant","attribute":"logo_url","kind":"image","data_type":"string","description":"The URL for a merchant logo. Merchant logos default to a size of 88x31.","required":false},{"response_section":"resources","xpath":"/response/resources/merchants/merchant","resource":"Merchant","attribute":"merchant_type","kind":"resource","data_type":"integer","description":"A merchant type ID for the merchant type the merchant belongs to.","required":false},{"response_section":"resources","xpath":"/response/resources/merchants/merchant","resource":"Merchant","attribute":"name","kind":"display","data_type":"string","description":"The name of the merchant.","required":true},{"response_section":"resources","xpath":"/response/resources/merchants/merchant","resource":"Merchant","attribute":"product_count","kind":"count","data_type":"integer","description":"The number of products offered by the merchant.","required":false},{"response_section":"resources","xpath":"/response/resources/merchants/merchant","resource":"Merchant","attribute":"site_url","kind":"direct_url","data_type":"string","description":"The direct URL to the merchant's website. This URL does NOT have any tracking information in it.","required":false},{"response_section":"resources","xpath":"/response/resources/merchants/merchant","resource":"Merchant","attribute":"url","kind":"redirect_url","data_type":"string","description":"The redirect URL that will pass along tracking information on a click.","required":false},{"response_section":"resources","xpath":"/response/resources/merchants/merchant","resource":"Merchant","attribute":"count","kind":"count","data_type":"integer","description":"A contextual count of offers or deals matching any query parameters.","required":false},{"response_section":"resources","xpath":"/response/resources/merchant_types/merchant_type","resource":"Attribute","attribute":"name","kind":"display","data_type":"string","description":"The name describing what type of attribute this is for the product. Examples of this are MPN, UPC, ISBN, etc.","required":true},{"response_section":"resources","xpath":"/response/resources/merchant_types/merchant_type","resource":"Attribute","attribute":"value","kind":"display","data_type":"string","description":"The actual value of the attribute for the product.","required":true},{"response_section":"results","xpath":"/response/results/deals/deal","resource":"Deal","attribute":"code","kind":"display","data_type":"string","description":"If a deal happens to be a coupon, this is the coupon code for it.","required":false},{"response_section":"results","xpath":"/response/results/deals/deal","resource":"Deal","attribute":"deal_type","kind":"resource","data_type":"integer","description":"This is the deal_type ID of the deal type the deal belongs to. it is possible for this to be a comma delimited list of deal type ids, if the deal belongs to more than one.","required":true},{"response_section":"results","xpath":"/response/results/deals/deal","resource":"Deal","attribute":"description","kind":"display","data_type":"string","description":"A merchant provided description of the deal.","required":false},{"response_section":"results","xpath":"/response/results/deals/deal","resource":"Deal","attribute":"end_on","kind":"display","data_type":"date","description":"The date the deal expires on.","required":false},{"response_section":"results","xpath":"/response/results/deals/deal","resource":"Deal","attribute":"id","kind":"primary_key","data_type":"integer","description":"The unique identifier for the deal in API calls.","required":true},{"response_section":"results","xpath":"/response/results/deals/deal","resource":"Deal","attribute":"image_url","kind":"image","data_type":"string","description":"The URL to an image for the deal.","required":false},{"response_section":"results","xpath":"/response/results/deals/deal","resource":"Deal","attribute":"merchant","kind":"resource","data_type":"integer","description":"The merchant ID of the merchant the deal belongs to.","required":true},{"response_section":"results","xpath":"/response/results/deals/deal","resource":"Deal","attribute":"name","kind":"display","data_type":"string","description":"The name of the deal.","required":true},{"response_section":"results","xpath":"/response/results/deals/deal","resource":"Deal","attribute":"restrictions","kind":"display","data_type":"string","description":"A description of any related restrictions on the deal that may limit its ability to be redeemed.","required":false},{"response_section":"results","xpath":"/response/results/deals/deal","resource":"Deal","attribute":"site_wide","kind":"display","data_type":"boolean","description":"Indicates whether or not the deal is applicable across a merchant's entire website, or limited to a specific product or category.","required":false},{"response_section":"results","xpath":"/response/results/deals/deal","resource":"Deal","attribute":"start_on","kind":"display","data_type":"date","description":"The starting date a deal is valid on.","required":false},{"response_section":"results","xpath":"/response/results/deals/deal","resource":"Deal","attribute":"url","kind":"redirect_url","data_type":"string","description":"A redirect URL that links to the deal landing page after passing along any tracking information for you.","required":true}],"request_url":"http://catalog.viglink.com/vigcatalog/deals.xml"},{"title":"Find merchants","description":"A call that enables you to find all merchants available within API calls.","format":"xml","required_parameters":[{"title":"key","description":"Your API account key.","parameter_type":"","parameter_kind":"account","allowed_values":"","default_value":"","required":true}],"optional_parameters":[{"title":"alpha","description":"A single letter that will filter on the first letter in a merchant name. Pass in the '#' symbol for non-alpha characters.","parameter_type":"item","parameter_kind":"filter","allowed_values":"#,a-z","default_value":"","required":false},{"title":"category","description":"A category ID to filter the merchants on.","parameter_type":"item","parameter_kind":"","allowed_values":"","default_value":"","required":false},{"title":"keyword","description":"A keyword or phrase to search merchant names on.","parameter_type":"","parameter_kind":"query","allowed_values":"","default_value":"","required":false},{"title":"merchant","description":"The merchant ID to filter the merchants on.","parameter_type":"selection","parameter_kind":"filter","allowed_values":"","default_value":"","required":false},{"title":"page","description":"The page number of results to return.","parameter_type":"item","parameter_kind":"pagination","allowed_values":"1-100","default_value":"1","required":false},{"title":"results_per_page","description":"The number of merchants to return in every response.","parameter_type":"item","parameter_kind":"pagination","allowed_values":"1-100","default_value":"20","required":false}],"response_nodes":[{"response_section":"resources","xpath":"/response/resources/categories/matches/category","resource":"Category","attribute":"id","kind":"primary_key","data_type":"integer","description":"The unique identifier for the category. This acts as a primary key that can be used to reference the category.","required":true},{"response_section":"resources","xpath":"/response/resources/categories/matches/category","resource":"Category","attribute":"leaf","kind":"display","data_type":"boolean","description":"Indicates whether or not the category is a leaf in the category tree and does not have any child categories.","required":false},{"response_section":"resources","xpath":"/response/resources/categories/matches/category","resource":"Category","attribute":"name","kind":"display","data_type":"string","description":"The display name of the category.","required":true},{"response_section":"resources","xpath":"/response/resources/categories/matches/category","resource":"Category","attribute":"count","kind":"count","data_type":"integer","description":"A contextual count of how many resources belong to a category that match any query parameters.","required":false},{"response_section":"resources","xpath":"/response/resources/countries/country","resource":"Country","attribute":"currency","kind":"display","data_type":"string","description":"The encoded currency symbol for a country.","required":false},{"response_section":"resources","xpath":"/response/resources/countries/country","resource":"Country","attribute":"id","kind":"primary_key","data_type":"integer","description":"The unique identifier for a country. This acts as a primary key that can be used to reference the country.","required":true},{"response_section":"resources","xpath":"/response/resources/countries/country","resource":"Country","attribute":"iso","kind":"display","data_type":"string","description":"The two character ISO code for the country.","required":false},{"response_section":"resources","xpath":"/response/resources/countries/country","resource":"Country","attribute":"iso3","kind":"display","data_type":"string","description":"The three character ISO3 code for the country.","required":false},{"response_section":"resources","xpath":"/response/resources/countries/country","resource":"Country","attribute":"merchant_count","kind":"count","data_type":"integer","description":"The number of merchants that belong to a country.","required":false},{"response_section":"resources","xpath":"/response/resources/countries/country","resource":"Country","attribute":"name","kind":"display","data_type":"string","description":"The display name of a country.","required":true},{"response_section":"resources","xpath":"/response/resources/merchant_types/merchant_type","resource":"Merchant type","attribute":"id","kind":"primary_key","data_type":"integer","description":"Unique identifier for a merchant type. This acts as a primary key that can be used to reference the merchant type.","required":true},{"response_section":"resources","xpath":"/response/resources/merchant_types/merchant_type","resource":"Merchant type","attribute":"merchant_count","kind":"count","data_type":"integer","description":"The number of merchants that belong to the merchant type.","required":false},{"response_section":"resources","xpath":"/response/resources/merchant_types/merchant_type","resource":"Merchant type","attribute":"name","kind":"display","data_type":"string","description":"The display name of the merchant type.","required":true},{"response_section":"results","xpath":"/response/results/merchants/merchant","resource":"Merchant","attribute":"category","kind":"resource","data_type":"integer","description":"A category ID for the category the merchant belongs to.","required":false},{"response_section":"results","xpath":"/response/results/merchants/merchant","resource":"Merchant","attribute":"country","kind":"resource","data_type":"integer","description":"A country ID for the country the merchant belongs to.","required":false},{"response_section":"results","xpath":"/response/results/merchants/merchant","resource":"Merchant","attribute":"deal_count","kind":"count","data_type":"integer","description":"The number of deals available from the merchant.","required":false},{"response_section":"results","xpath":"/response/results/merchants/merchant","resource":"Merchant","attribute":"id","kind":"primary_key","data_type":"integer","description":"The unique identifier for the merchant within the API. This acts as a primary key that can be used to reference the merchant.","required":true},{"response_section":"results","xpath":"/response/results/merchants/merchant","resource":"Merchant","attribute":"logo_url","kind":"image","data_type":"string","description":"The URL for a merchant logo. Merchant logos default to a size of 88x31.","required":false},{"response_section":"results","xpath":"/response/results/merchants/merchant","resource":"Merchant","attribute":"merchant_type","kind":"resource","data_type":"integer","description":"A merchant type ID for the merchant type the merchant belongs to.","required":false},{"response_section":"results","xpath":"/response/results/merchants/merchant","resource":"Merchant","attribute":"name","kind":"display","data_type":"string","description":"The name of the merchant.","required":true},{"response_section":"results","xpath":"/response/results/merchants/merchant","resource":"Merchant","attribute":"product_count","kind":"count","data_type":"integer","description":"The number of products offered by the merchant.","required":false},{"response_section":"results","xpath":"/response/results/merchants/merchant","resource":"Merchant","attribute":"site_url","kind":"direct_url","data_type":"string","description":"The direct URL to the merchant's website. This URL does NOT have any tracking information in it.","required":false},{"response_section":"results","xpath":"/response/results/merchants/merchant","resource":"Merchant","attribute":"url","kind":"redirect_url","data_type":"string","description":"The redirect URL that will pass along tracking information on a click.","required":false},{"response_section":"results","xpath":"/response/results/merchants/merchant","resource":"Merchant","attribute":"count","kind":"count","data_type":"integer","description":"A contextual count of offers or deals matching any query parameters.","required":false}],"request_url":"http://catalog.viglink.com/vigcatalog/merchants.xml"},{"title":"Find merchant types","description":"Merchant types are used to categorize merchants themselves by the broad type of store they are.","format":"xml","required_parameters":[{"title":"key","description":"Your API account key.","parameter_type":"","parameter_kind":"account","allowed_values":"","default_value":"","required":true}],"optional_parameters":[],"response_nodes":[{"response_section":"results","xpath":"/response/results/merchant_types/merchant_type","resource":"Merchant type","attribute":"id","kind":"primary_key","data_type":"integer","description":"Unique identifier for a merchant type. This acts as a primary key that can be used to reference the merchant type.","required":true},{"response_section":"results","xpath":"/response/results/merchant_types/merchant_type","resource":"Merchant type","attribute":"merchant_count","kind":"count","data_type":"integer","description":"The number of merchants that belong to the merchant type.","required":false},{"response_section":"results","xpath":"/response/results/merchant_types/merchant_type","resource":"Merchant type","attribute":"name","kind":"display","data_type":"string","description":"The display name of the merchant type.","required":true}],"request_url":"http://catalog.viglink.com/vigcatalog/merchant_types.xml"},{"title":"Find deal types","description":"A deal type is used to categorize a deal. You can use deal_type ids to further filter product/deal queries.","format":"xml","required_parameters":[{"title":"key","description":"Your API account key.","parameter_type":"","parameter_kind":"account","allowed_values":"","default_value":"","required":true}],"optional_parameters":[],"response_nodes":[{"response_section":"results","xpath":"/response/results/deal_types/deal_type","resource":"Deal type","attribute":"id","kind":"primary_key","data_type":"integer","description":"The unique identifier for a deal type. This acts as a primary key that can be used to reference the deal type.","required":true},{"response_section":"results","xpath":"/response/results/deal_types/deal_type","resource":"Deal type","attribute":"name","kind":"display","data_type":"string","description":"The display name of the deal type.","required":true},{"response_section":"results","xpath":"/response/results/deal_types/deal_type","resource":"Deal type","attribute":"deal_count","kind":"count","data_type":"integer","description":"A count of deals that belong to the deal type.","required":false}],"request_url":"http://catalog.viglink.com/vigcatalog/deal_types.xml"},{"title":"Find countries","description":"Countries are used to identify where a particular merchant's offers are located.","format":"xml","required_parameters":[{"title":"key","description":"Your API account key.","parameter_type":"","parameter_kind":"account","allowed_values":"","default_value":"","required":true}],"optional_parameters":[],"response_nodes":[{"response_section":"results","xpath":"/response/results/countries/country","resource":"Country","attribute":"currency","kind":"display","data_type":"string","description":"The encoded currency symbol for a country.","required":false},{"response_section":"results","xpath":"/response/results/countries/country","resource":"Country","attribute":"id","kind":"primary_key","data_type":"integer","description":"The unique identifier for a country. This acts as a primary key that can be used to reference the country.","required":true},{"response_section":"results","xpath":"/response/results/countries/country","resource":"Country","attribute":"iso","kind":"display","data_type":"string","description":"The two character ISO code for the country.","required":false},{"response_section":"results","xpath":"/response/results/countries/country","resource":"Country","attribute":"iso3","kind":"display","data_type":"string","description":"The three character ISO3 code for the country.","required":false},{"response_section":"results","xpath":"/response/results/countries/country","resource":"Country","attribute":"merchant_count","kind":"count","data_type":"integer","description":"The number of merchants that belong to a country.","required":false},{"response_section":"results","xpath":"/response/results/countries/country","resource":"Country","attribute":"name","kind":"display","data_type":"string","description":"The display name of a country.","required":true}],"request_url":"http://catalog.viglink.com/vigcatalog/countries.xml"}]},
25
+ $api = $("#api"),
26
+ $content = $("#content"),
27
+ $nav = $("#nav"),
28
+ paramHeader = "<thead><tr><th>Param name</th><th>Type</th><th>Kind</th><th>Allowed values</th><th>Default value</th><th>Description</th></tr></thead>";
29
+
30
+ $content.append( "<h1>" + api.title + "</h1>" );
31
+ $content.append( "<p>" + api.description + "</p>" );
32
+ $content.append( "<h2>Base API URL</h2>" );
33
+ $content.append( "<p>" + api.base_url + "</p>" );
34
+
35
+ $content.append("<h2>Guides</h2>");
36
+ $nav.append("<h3>Guides</h3>");
37
+ for(var i=0; i < api.guides.length; i++) {
38
+ var guide = api.guides[i],
39
+ guideId = guide.title.replace( " ", "_" ),
40
+ $guide = $( "<div id=\"#" + guideId + "\"></div>" );
41
+
42
+ $nav.append( "<a href=\"#" + guideId + "\">" + guide.title + "</a>" );
43
+ $guide.append( "<a name=\"" + guideId + "\"></a>" );
44
+ $guide.append( "<h3>" + guide.title + "</h3>" );
45
+ $guide.append( "<p>" + guide.description+"</p>" );
46
+ $content.append($guide);
47
+ }
48
+
49
+ $content.append("<h2>API calls</h2>");
50
+ $nav.append("<h3>API Calls</h3>");
51
+ for(var i=0; i < api.calls.length; i++) {
52
+ var call = api.calls[i],
53
+ callId = call.title.replace( " ", "_" ),
54
+ $call = $( "<div id=\"" + callId + "\"></div>" ),
55
+ $requiredParamTable = $("<table>"),
56
+ $optionalParamTable = $("<table>"),
57
+ $responseTable = $("<table>");
58
+
59
+ $nav.append( "<a href=\"#" + callId + "\">" + call.title + "</a>" );
60
+ $call.append( "<a name=\"" + callId + "\"></a>" );
61
+ $call.append( "<h3>" + call.title + "</h3>" );
62
+
63
+ $call.append("<h4>Request URL</h4>");
64
+ $call.append( "<p>" + call.request_url + "</p>" );
65
+
66
+ $call.append("<h4>Response formats</h4>");
67
+ $call.append("<p>" + call.format + "</p>");
68
+
69
+ if (call.required_parameters.length > 0) {
70
+ $call.append("<h4>Required parameters</h4>");
71
+ $requiredParamTable.append(paramHeader);
72
+ var $tbody = $("<tbody></tbody>");
73
+ for(var x = 0; x < call.required_parameters.length; x++) {
74
+ var param = call.required_parameters[x],
75
+ $row = buildParamRow(param);
76
+ $tbody.append($row);
77
+ }
78
+ $requiredParamTable.append($tbody);
79
+ $call.append($requiredParamTable);
80
+ }
81
+
82
+ if (call.optional_parameters.length > 0) {
83
+ $call.append("<h4>Optional parameters</h4>");
84
+ $optionalParamTable.append(paramHeader);
85
+ var $tbody = $("<tbody></tbody>");
86
+ for(var x = 0; x < call.optional_parameters.length; x++) {
87
+ var param = call.optional_parameters[x],
88
+ $row = buildParamRow(param);
89
+ $tbody.append($row);
90
+ }
91
+ $optionalParamTable.append($tbody);
92
+ $call.append($optionalParamTable);
93
+ }
94
+
95
+ $call.append("<h4>Response</h4>");
96
+ $responseTable.append("<thead><tr><th>Section</th><th class=\"xpath\">Xpath</th><th>Resource</th><th>Attribute</th><th>Required</th><th>Kind</th><th>Data type</th><th>Description</th></tr></thead>")
97
+ var $tbody = $("<tbody>");
98
+ for(var x = 0; x < call.response_nodes.length; x++) {
99
+ var node = call.response_nodes[x],
100
+ $row = $("<tr></tr>");
101
+ $row.append( "<td>" + node.response_section + "</td>" );
102
+ $row.append( "<td>" + node.xpath + "</td>" );
103
+ $row.append( "<td>" + node.resource + "</td>" );
104
+ $row.append( "<td>" + node.attribute + "</td>" );
105
+ $row.append( "<td>" + node.required + "</td>" );
106
+ $row.append( "<td>" + node.kind + "</td>" );
107
+ $row.append( "<td>" + node.data_type + "</td>" );
108
+ $row.append( "<td>" + node.description + "</td>" );
109
+ $tbody.append($row);
110
+ }
111
+ $responseTable.append($tbody);
112
+ $call.append($responseTable);
113
+ $content.append($call);
114
+ }
115
+
116
+ function buildParamRow(param) {
117
+ var $row = $("<tr>");
118
+ $row.append( "<td>" + param.title + "</td>" );
119
+ $row.append( "<td>" + param.parameter_type + "</td>" );
120
+ $row.append( "<td>" + param.parameter_kind + "</td>" );
121
+ $row.append( "<td>" + param.allowed_values + "</td>" );
122
+ $row.append( "<td>" + param.default_value + "</td>" );
123
+ $row.append( "<td>" + param.description + "</td>" );
124
+ return $row;
125
+ }
126
+
127
+ </script>
128
+ </body>
129
+ </html>
@@ -0,0 +1,46 @@
1
+ require 'faraday'
2
+ require 'faraday_middleware'
3
+ require 'viglink_api/version'
4
+ require 'viglink_api/client'
5
+ require 'viglink_api/purchases'
6
+
7
+ # directory = File.expand_path(File.dirname(__FILE__))
8
+
9
+ module ViglinkApi
10
+
11
+ class << self
12
+ attr_accessor :api_url, :api_key, :api_secret, :api_full_response, :api_cuid_url
13
+
14
+ ##
15
+ # Configure default credentials
16
+ #
17
+ # @yield [ViglinkApi]
18
+ def configure
19
+ load_defaults
20
+ yield self
21
+ true
22
+ end
23
+
24
+ private
25
+
26
+ def load_defaults
27
+ self.api_url ||= 'http://catalog.viglink.com'
28
+ self.api_key ||= nil
29
+ self.api_secret ||= nil
30
+ self.api_full_response ||= true
31
+
32
+ self.api_cuid_url ||= 'https://www.viglink.com/service/v1/cuidRevenue'
33
+ end
34
+
35
+ end
36
+
37
+ end
38
+
39
+ # class String
40
+ # def to_bool
41
+ # return true if self == true || self =~ (/(true|t|yes|y|1)$/i)
42
+ # return false if self == false || self.blank? || self =~ (/(false|f|no|n|0)$/i)
43
+ # raise ArgumentError.new("invalid value for Boolean: \"#{self}\"")
44
+ # end
45
+ # end
46
+
@@ -0,0 +1,56 @@
1
+ # encoding: utf-8
2
+ require 'forwardable'
3
+ require 'viglink_api/request'
4
+ require 'viglink_api/product'
5
+ require 'viglink_api/deal'
6
+ require 'viglink_api/merchant'
7
+ require 'viglink_api/country'
8
+
9
+ module ViglinkApi
10
+ class Client
11
+ extend Forwardable
12
+
13
+ include Request
14
+ include Product
15
+ include Deal
16
+ include Merchant
17
+ include Country
18
+
19
+ attr_reader :api_key, :api_url, :api_full_response
20
+
21
+ ##
22
+ # Create a new Viglink::Client object
23
+ #
24
+ # @params options [Hash]
25
+ def initialize(options={})
26
+ @api_key = options[:api_key] || ViglinkApi.api_key
27
+ @api_url = options[:api_url] || ViglinkApi.api_url
28
+ @api_full_response = options[:api_full_response] || ViglinkApi.api_full_response
29
+ end
30
+
31
+ ##
32
+ # Create a Faraday::Connection object
33
+ #
34
+ # @return [Faraday::Connection]
35
+ def connection
36
+ params = {}
37
+ @connection = Faraday.new(url: api_url, params: params, headers: default_headers) do |faraday|
38
+ faraday.use FaradayMiddleware::Mashify
39
+ faraday.use FaradayMiddleware::ParseXml, content_type: /\bxml$/
40
+ # faraday.request :url_encoded
41
+ faraday.adapter Faraday.default_adapter
42
+ end
43
+ end
44
+
45
+ private
46
+
47
+ def default_headers
48
+ headers = {
49
+ accept: '*/*',
50
+ content_type: 'text/xml',
51
+ user_agent: "Ruby Gem #{ViglinkApi::VERSION}"
52
+ }
53
+ end
54
+
55
+ end
56
+ end