popshops-api 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 6a76d6ac0bc4d72065087b079b7dd17f7d079a3e
4
+ data.tar.gz: e066d2c165989834612d796cb88fe5a7577d0b93
5
+ SHA512:
6
+ metadata.gz: 977aa3f9c3a7faf78c9dcbc843a0816920b5cb6a1f062d5a83345fc0655227e5b462a97c0f69adc503851aae02f04d2beb58668a08a33c5c56ffeb7e69257d7c
7
+ data.tar.gz: 579d0268afa4f12a87bef9a7751aac45601401cb4e94df65f5bfec64cec6656e11ece2cede12d49e6ec4de7199116fec63800f6e7e76c026dc720717c737f3c1
@@ -0,0 +1,20 @@
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
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ .ruby-version
19
+ .ruby-gemset
20
+ .env
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in popshops.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Ben Eggett
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,75 @@
1
+ # Popshops
2
+
3
+ A lightweight Ruby wrapper for communicating with the latest PopShops API (v3).
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'popshops'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install popshops
18
+
19
+ ## Usage
20
+
21
+ `require 'popshops-api'` as needed
22
+
23
+ Initialize the Popshops API
24
+
25
+ ``` ruby
26
+ popshops = Popshops::Api.new('api_key_value', 'catalog_key_value' )
27
+ ```
28
+
29
+ Options:
30
+ * api_key: Required
31
+ * catalog_key: Optional, but needed in many calls.
32
+ * private_api_key: Optional, if your account supports it.
33
+ * format: Optional. Can be :json or :xml. Defaults to :json
34
+
35
+ You can always switch popshops catalogs by reinitializing popshops, or utilizing the following method:
36
+
37
+ ``` ruby
38
+ popshops.use_catalog('new_catalog_key')
39
+ ```
40
+ You're now ready to start receiving data from Popshops.
41
+ All of the PopShops API methods are available as:
42
+
43
+ * find_products
44
+ * find_coupons_and_deals
45
+ * find_merchants
46
+ * list_categories
47
+ * list_merchant_types
48
+ * list_deal_types
49
+ * list_networks
50
+ * list_countries
51
+ * list_keywords
52
+
53
+ ### [Find Products](http://popshops.com/support/api-3-products)
54
+
55
+ 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 affiliate links associated with them, the product itself will not have an affiliate URL.
56
+
57
+ To lookup all products in your catalog, call:
58
+ ``` ruby
59
+ popshops.find_products
60
+ ```
61
+
62
+ To search for products by keyword, call:
63
+ ```
64
+ popshops.find_products(keyword: 'ipad')
65
+ ```
66
+
67
+ More details to come for other sections.
68
+
69
+ ## Contributing
70
+
71
+ 1. Fork it ( http://github.com/beneggett/popshops-api/fork )
72
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
73
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
74
+ 4. Push to the branch (`git push origin my-new-feature`)
75
+ 5. Create new Pull Request
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,66 @@
1
+ # require "popshops/version"
2
+ require "rubygems"
3
+ require "httparty"
4
+ require "hashie"
5
+
6
+ module Popshops
7
+ class Api
8
+ include HTTParty
9
+ base_uri 'api.popshops.com/v3'
10
+ attr_accessor :api_key, :catalog_key, :private_api_key, :format
11
+
12
+ def initialize(api_key, catalog_key = nil, private_api_key = nil, format = :json)
13
+ @api_key = api_key
14
+ @catalog_key = catalog_key
15
+ @private_api_key = private_api_key
16
+ @format = format
17
+ end
18
+
19
+ def use_catalog(catalog_key)
20
+ @catalog_key = catalog_key
21
+ end
22
+
23
+ def find_products(options={})
24
+ Hashie::Mash.new( self.class.get "/products.#{@format}", query: merged(options) )
25
+ end
26
+
27
+ def find_coupons_and_deals(options={})
28
+ Hashie::Mash.new( self.class.get "/deals.#{@format}", query: merged(options) )
29
+ end
30
+
31
+ def find_merchants(options={})
32
+ Hashie::Mash.new( self.class.get "/merchants.#{@format}", query: merged(options) )
33
+ end
34
+
35
+ def list_categories(options={})
36
+ Hashie::Mash.new( self.class.get "/categories.#{@format}", query: merged(options) )
37
+ end
38
+
39
+ def list_merchant_types(options={})
40
+ Hashie::Mash.new( self.class.get "/merchant_types.#{@format}", query: merged(options) )
41
+ end
42
+
43
+ def list_deal_types(options={})
44
+ Hashie::Mash.new( self.class.get "/deal_types.#{@format}", query: merged(options) )
45
+ end
46
+
47
+ def list_networks(options={})
48
+ Hashie::Mash.new( self.class.get "/networks.#{@format}", query: merged(options) )
49
+ end
50
+
51
+ def list_countries(options={})
52
+ Hashie::Mash.new( self.class.get "/countries.#{@format}", query: merged(options) )
53
+ end
54
+
55
+ def list_keywords(options={})
56
+ Hashie::Mash.new( self.class.get "/keywords.#{@format}", query: merged(options) )
57
+ end
58
+
59
+ private
60
+ # This is used in all calls to merge our account & catalog parameters into the options queries
61
+ def merged(options)
62
+ { account: @api_key, catalog: @catalog_key}.merge(options)
63
+ end
64
+
65
+ end
66
+ end
@@ -0,0 +1,3 @@
1
+ module Popshops
2
+ VERSION = "2.0.0"
3
+ end
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'popshops/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "popshops-api"
8
+ spec.version = Popshops::VERSION
9
+ spec.authors = ["Ben Eggett"]
10
+ spec.email = ["beneggett@gmail.com"]
11
+ spec.summary = %q{A Ruby wrapper for working with Popshops latest API (v3).}
12
+ spec.description = %q{A simple ruby wrapper using httparty and Hashie to communicate with popshops API methods and work with data in nice ruby way.}
13
+ spec.homepage = "http://www.github.com/beneggett/popshops-api"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.5"
22
+ spec.add_development_dependency "rake"
23
+ spec.add_development_dependency "rspec"
24
+ spec.add_dependency "httparty", "~> 0.8.0"
25
+ spec.add_dependency "hashie", "~> 2.0"
26
+ end
metadata ADDED
@@ -0,0 +1,123 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: popshops-api
3
+ version: !ruby/object:Gem::Version
4
+ version: 2.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Ben Eggett
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-03-03 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.5'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.5'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: httparty
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 0.8.0
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: 0.8.0
69
+ - !ruby/object:Gem::Dependency
70
+ name: hashie
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ~>
74
+ - !ruby/object:Gem::Version
75
+ version: '2.0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ~>
81
+ - !ruby/object:Gem::Version
82
+ version: '2.0'
83
+ description: A simple ruby wrapper using httparty and Hashie to communicate with popshops
84
+ API methods and work with data in nice ruby way.
85
+ email:
86
+ - beneggett@gmail.com
87
+ executables: []
88
+ extensions: []
89
+ extra_rdoc_files: []
90
+ files:
91
+ - .gitignore
92
+ - Gemfile
93
+ - LICENSE.txt
94
+ - README.md
95
+ - Rakefile
96
+ - lib/popshops.rb
97
+ - lib/popshops/version.rb
98
+ - popshops.gemspec
99
+ homepage: http://www.github.com/beneggett/popshops-api
100
+ licenses:
101
+ - MIT
102
+ metadata: {}
103
+ post_install_message:
104
+ rdoc_options: []
105
+ require_paths:
106
+ - lib
107
+ required_ruby_version: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - '>='
110
+ - !ruby/object:Gem::Version
111
+ version: '0'
112
+ required_rubygems_version: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - '>='
115
+ - !ruby/object:Gem::Version
116
+ version: '0'
117
+ requirements: []
118
+ rubyforge_project:
119
+ rubygems_version: 2.2.2
120
+ signing_key:
121
+ specification_version: 4
122
+ summary: A Ruby wrapper for working with Popshops latest API (v3).
123
+ test_files: []