lomadee 0.0.4

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: f1f6d5f0654e9c17f98492248a370547c996d905
4
+ data.tar.gz: 8c95afdf52adb44a8a342ec3dd0a5928edd63c22
5
+ SHA512:
6
+ metadata.gz: bae6c5f0d91597f9f8904dbc08d1ef073adc4d40347b2df1756bb14b780ce4f0cb850231fc97b2cac344f13a17ed881fb22a15e6c7c2e2f5cbe4b0a8e3932e7a
7
+ data.tar.gz: ca571e85df7fcac0cbdc8e8b1de40b3cc65e9b0479138b53e064fb29fb443dbd7256bf6a0ae640e2295eee8e7f094631e2a028bc4feb15ddeb770961e895d1d9
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
@@ -0,0 +1,40 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ lomadee (0.0.1)
5
+ httparty
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ awesome_print (1.2.0)
11
+ coderay (1.0.9)
12
+ diff-lcs (1.2.4)
13
+ httparty (0.11.0)
14
+ multi_json (~> 1.0)
15
+ multi_xml (>= 0.5.2)
16
+ method_source (0.8.2)
17
+ multi_json (1.8.0)
18
+ multi_xml (0.5.5)
19
+ pry (0.9.12.2)
20
+ coderay (~> 1.0.5)
21
+ method_source (~> 0.8)
22
+ slop (~> 3.4)
23
+ rspec (2.14.1)
24
+ rspec-core (~> 2.14.0)
25
+ rspec-expectations (~> 2.14.0)
26
+ rspec-mocks (~> 2.14.0)
27
+ rspec-core (2.14.5)
28
+ rspec-expectations (2.14.3)
29
+ diff-lcs (>= 1.1.3, < 2.0)
30
+ rspec-mocks (2.14.3)
31
+ slop (3.4.6)
32
+
33
+ PLATFORMS
34
+ ruby
35
+
36
+ DEPENDENCIES
37
+ awesome_print
38
+ lomadee!
39
+ pry
40
+ rspec
@@ -0,0 +1,28 @@
1
+ == Lomadee
2
+
3
+ This is the lightweight wrapper for Lomadee API. (http://developer.buscape.com/api/api-e-documentacao-lomadee)
4
+
5
+ = How to install?
6
+
7
+ Simple as:
8
+
9
+ gem install lomadee
10
+
11
+ = How to use?
12
+
13
+ First instantiate a new 'Lomadee::Base' object with two parameters (application_id, sandbox? (default: false)), for example:
14
+
15
+ lomadee = Lomadee::Base.new("you_application_id")
16
+
17
+ Then you can use like this:
18
+
19
+ lomadee.category(77).products
20
+
21
+ This get all products in the cellphone category. Or like this:
22
+
23
+ lomadee.keyword("Apple").products
24
+
25
+ This get all products using the keyword "Apple"
26
+
27
+
28
+ Help me improving this gem (and the documentation of course)! Fork this project and feel free to help. :)
@@ -0,0 +1,6 @@
1
+ require 'httparty'
2
+ require 'uri'
3
+
4
+ module Lomadee
5
+ autoload :Base, 'lomadee/base.rb'
6
+ end
@@ -0,0 +1,59 @@
1
+ module Lomadee
2
+ class Base
3
+ include HTTParty
4
+
5
+ def initialize(application_id, sandbox = false)
6
+ raise "You need to inform your :application_id" if application_id.nil?
7
+
8
+ @env = (sandbox) ? 'sandbox' : 'bws'
9
+
10
+ @application_id = application_id
11
+
12
+ @uris = {
13
+ :offers => "findOfferList",
14
+ :products => "findProductList",
15
+ :categories => "findCategoryList",
16
+ :create_link => "createLinks"
17
+ }
18
+
19
+ @params = {
20
+ :category => "categoryId",
21
+ :product => "productId",
22
+ :barcode => "barcode",
23
+ :keyword => "keyword"
24
+ }
25
+
26
+ @data = {}
27
+ end
28
+
29
+ private
30
+
31
+ def method_missing(method, *args, &block)
32
+ if @uris.map {|v, k| v }.include? method
33
+ @data.merge!(args[0])
34
+ fetch_api(method)
35
+ else
36
+ @data.merge!({method => args[0]})
37
+ self
38
+ end
39
+ end
40
+
41
+ def fetch_api(method)
42
+ raise "Method '#{method}' doesn't exist!" if @uris[method].empty?
43
+
44
+ @uris[method] = "viewSellerDetails" if method === :details && !@data[:seller].blank? && @data[:product].blank?
45
+
46
+ url = "http://#{@env}.buscape.com/service/#{@uris[method]}/lomadee/#{@application_id}/"
47
+
48
+ @data.each { |sym, value|
49
+ url += ((url[-1, 1] == "/") ? "?" : "&") + "#{(@params[sym].nil?) ? sym.to_s : @params[sym]}=#{value}"
50
+ }
51
+
52
+ uri_parser = URI::Parser.new
53
+
54
+ res = self.class.get(uri_parser.escape(url))
55
+
56
+ res.parsed_response["Result"] unless res.nil?
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,3 @@
1
+ module Lomadee
2
+ VERSION = "0.0.4"
3
+ end
@@ -0,0 +1,25 @@
1
+ $:.push File.expand_path("../lib", __FILE__)
2
+ require "lomadee/version"
3
+
4
+ Gem::Specification.new do |s|
5
+ s.name = "lomadee"
6
+ s.version = Lomadee::VERSION
7
+ s.platform = Gem::Platform::RUBY
8
+ s.authors = ["Bruno A. da Costa"]
9
+ s.email = ["brunoadacosta@gmail.com"]
10
+ s.homepage = "http://rubygems.org/gems/lomadee"
11
+ s.summary = "A lightweight Ruby wrapper for Buscapé API"
12
+ s.description = s.summary
13
+ s.license = 'MIT'
14
+
15
+ s.files = `git ls-files`.split($\)
16
+ s.executables = s.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ s.test_files = s.files.grep(%r{^(test|spec|features)/})
18
+ s.require_paths = ["lib"]
19
+
20
+ s.add_dependency "httparty"
21
+
22
+ s.add_development_dependency "awesome_print"
23
+ s.add_development_dependency "pry"
24
+ s.add_development_dependency "rspec"
25
+ end
metadata ADDED
@@ -0,0 +1,107 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: lomadee
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.4
5
+ platform: ruby
6
+ authors:
7
+ - Bruno A. da Costa
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-10-14 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: httparty
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: awesome_print
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: pry
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: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: A lightweight Ruby wrapper for Buscapé API
70
+ email:
71
+ - brunoadacosta@gmail.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - Gemfile
77
+ - Gemfile.lock
78
+ - README.rdoc
79
+ - lib/lomadee.rb
80
+ - lib/lomadee/base.rb
81
+ - lib/lomadee/version.rb
82
+ - lomadee.gemspec
83
+ homepage: http://rubygems.org/gems/lomadee
84
+ licenses:
85
+ - MIT
86
+ metadata: {}
87
+ post_install_message:
88
+ rdoc_options: []
89
+ require_paths:
90
+ - lib
91
+ required_ruby_version: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - '>='
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
96
+ required_rubygems_version: !ruby/object:Gem::Requirement
97
+ requirements:
98
+ - - '>='
99
+ - !ruby/object:Gem::Version
100
+ version: '0'
101
+ requirements: []
102
+ rubyforge_project:
103
+ rubygems_version: 2.1.6
104
+ signing_key:
105
+ specification_version: 4
106
+ summary: A lightweight Ruby wrapper for Buscapé API
107
+ test_files: []