meli 1.0.3.1 → 1.0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +13 -0
- data/.rubocop.yml +23 -0
- data/.travis.yml +6 -0
- data/Gemfile +11 -0
- data/Gemfile.lock +45 -0
- data/README.md +129 -0
- data/Rakefile +11 -0
- data/examples/delete.rb +20 -0
- data/examples/example_login.rb +21 -0
- data/examples/get.rb +17 -0
- data/examples/post.rb +41 -0
- data/examples/put.rb +18 -0
- data/lib/config.yml +18 -2
- data/meli.gemspec +29 -0
- metadata +47 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 052a314ec914a08547634f5f03c9dfae1da3e7dc
|
4
|
+
data.tar.gz: e3b19a220a1946f9487b2169ea2ee83a9b3cce17
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bbb7fb0143444f7f7952e889ebe29c9c1293f13ef6739e03cd020a49b2c764ef38ccd831720da1110645b3bd119b512b7b7c8ecac2cd9b282987861bc4adaf77
|
7
|
+
data.tar.gz: 59ba84bdfc94c3a3d05a7c7344936e7db7b2de07cf91ea164dba2d3199d66e18eb1288e3bf4c3b3cd6c566b4694443af1ba6ed9a924de6ac859e4e2bacd318f6
|
data/.gitignore
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
Lint/UselessAssignment:
|
2
|
+
Enabled: false
|
3
|
+
|
4
|
+
Metrics/ClassLength:
|
5
|
+
Enabled: false
|
6
|
+
|
7
|
+
Metrics/MethodLength:
|
8
|
+
Enabled: false
|
9
|
+
|
10
|
+
Metrics/AbcSize:
|
11
|
+
Enabled: false
|
12
|
+
|
13
|
+
Lint/Void:
|
14
|
+
Enabled: false
|
15
|
+
|
16
|
+
Metrics/LineLength:
|
17
|
+
Max: 130
|
18
|
+
|
19
|
+
Style/GuardClause:
|
20
|
+
Enabled: false
|
21
|
+
|
22
|
+
Metrics/BlockNesting:
|
23
|
+
Max: 5
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
meli (1.0.3.2)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
ast (2.2.0)
|
10
|
+
json (1.8.3)
|
11
|
+
parser (2.3.0.7)
|
12
|
+
ast (~> 2.2)
|
13
|
+
powerpack (0.1.1)
|
14
|
+
rack (1.6.4)
|
15
|
+
rack-protection (1.5.3)
|
16
|
+
rack
|
17
|
+
rainbow (2.1.0)
|
18
|
+
rake (11.1.2)
|
19
|
+
rubocop (0.39.0)
|
20
|
+
parser (>= 2.3.0.7, < 3.0)
|
21
|
+
powerpack (~> 0.1)
|
22
|
+
rainbow (>= 1.99.1, < 3.0)
|
23
|
+
ruby-progressbar (~> 1.7)
|
24
|
+
unicode-display_width (~> 1.0, >= 1.0.1)
|
25
|
+
ruby-progressbar (1.7.5)
|
26
|
+
sinatra (1.4.7)
|
27
|
+
rack (~> 1.5)
|
28
|
+
rack-protection (~> 1.4)
|
29
|
+
tilt (>= 1.3, < 3)
|
30
|
+
tilt (2.0.2)
|
31
|
+
unicode-display_width (1.0.3)
|
32
|
+
|
33
|
+
PLATFORMS
|
34
|
+
ruby
|
35
|
+
|
36
|
+
DEPENDENCIES
|
37
|
+
bundler (~> 1.8)
|
38
|
+
json
|
39
|
+
meli!
|
40
|
+
rake
|
41
|
+
rubocop
|
42
|
+
sinatra
|
43
|
+
|
44
|
+
BUNDLED WITH
|
45
|
+
1.11.2
|
data/README.md
ADDED
@@ -0,0 +1,129 @@
|
|
1
|
+
# MercadoLibre's Ruby SDK
|
2
|
+
[![Build Status](https://travis-ci.org/AlfredoBejarano/ruby-sdk.svg?branch=master)](https://travis-ci.org/AlfredoBejarano/ruby-sdk)
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/meli.svg)](https://badge.fury.io/rb/meli)
|
4
|
+
|
5
|
+
This is fork from the [Ruby SDK for MercadoLibre's Platform](https://github.com/mercadolibre/ruby-sdk).
|
6
|
+
|
7
|
+
## How do I install it?
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
# in the file.rb
|
11
|
+
require 'meli'
|
12
|
+
|
13
|
+
# and in your Gemfile
|
14
|
+
gem 'meli'
|
15
|
+
```
|
16
|
+
The gem requires Ruby 2.2 or superior.
|
17
|
+
|
18
|
+
Check the [Gem Page](https://rubygems.org/gems/meli) at RubyGems.org.
|
19
|
+
|
20
|
+
Start the development!
|
21
|
+
|
22
|
+
## How do I use it?
|
23
|
+
|
24
|
+
The first thing to do is to instance a ```Meli``` class. You'll need to give a ```clientId``` and a ```clientSecret```. You can obtain both after creating your own application. For more information on this please read: [creating an application](http://developers.mercadolibre.com/application-manager/)
|
25
|
+
|
26
|
+
|
27
|
+
### Create an instance of Meli class
|
28
|
+
Simple like this
|
29
|
+
```ruby
|
30
|
+
meli = Meli.new(1234, "a secret")
|
31
|
+
```
|
32
|
+
With this instance you can start working on MercadoLibre's APIs.
|
33
|
+
|
34
|
+
There are some design considerations worth to mention.
|
35
|
+
|
36
|
+
1. This SDK is just a thin layer on top of an http client to handle all the OAuth WebServer flow for you.
|
37
|
+
|
38
|
+
2. There is JSON parsing. this SDK will include [json](http://rubygems.org/gems/json) gem for internal usage.
|
39
|
+
|
40
|
+
3. If you already have the access_token and the refresh_token you can pass in the constructor
|
41
|
+
|
42
|
+
```ruby
|
43
|
+
meli = Meli.new(1234, "a secret", "Access_Token", "Refresh_Token")
|
44
|
+
```
|
45
|
+
|
46
|
+
## How do I redirect users to authorize my application?
|
47
|
+
|
48
|
+
This is a 2 step process.
|
49
|
+
|
50
|
+
First get the link to redirect the user. This is very easy! Just:
|
51
|
+
|
52
|
+
```ruby
|
53
|
+
redirectUrl = meli.auth_url("http://somecallbackurl")
|
54
|
+
```
|
55
|
+
|
56
|
+
This will give you the url to redirect the user. You need to specify a callback url which will be the one that the user will redirected after a successfull authrization process.
|
57
|
+
|
58
|
+
Once the user is redirected to your callback url, you'll receive in the query string, a parameter named ```code```. You'll need this for the second part of the process.
|
59
|
+
|
60
|
+
```ruby
|
61
|
+
meli.authorize("the received code", "http://somecallbackurl")
|
62
|
+
```
|
63
|
+
|
64
|
+
This will get an ```access_token``` and a ```refresh_token``` (is case your application has the ```offline_access```) for your application and your user.
|
65
|
+
|
66
|
+
At this stage your are ready to make call to the API on behalf of the user.
|
67
|
+
|
68
|
+
#### Making GET calls
|
69
|
+
|
70
|
+
```ruby
|
71
|
+
params = {:access_token => meli.access_token}
|
72
|
+
response = meli.get("/users/me", params)
|
73
|
+
```
|
74
|
+
|
75
|
+
The response body will not be converted from json to Ruby hash
|
76
|
+
|
77
|
+
Look this simple way to resolve this:
|
78
|
+
|
79
|
+
```ruby
|
80
|
+
#convert json into a ruby hash
|
81
|
+
resp_hash = JSON.parse response.body
|
82
|
+
puts resp_hahs["KEY"]
|
83
|
+
```
|
84
|
+
|
85
|
+
#### Making POST calls
|
86
|
+
|
87
|
+
```ruby
|
88
|
+
params = {:access_token => meli.access_token}
|
89
|
+
|
90
|
+
#we are cool, the sdk will convert this body into json for you
|
91
|
+
body = {:foo => "bar", :bar => "foo"}
|
92
|
+
|
93
|
+
response = meli.post("/items", body, params)
|
94
|
+
```
|
95
|
+
|
96
|
+
#### Making PUT calls
|
97
|
+
|
98
|
+
```ruby
|
99
|
+
params = {:access_token => meli.access_token}
|
100
|
+
|
101
|
+
#we are cool, the sdk will convert this body into json for you
|
102
|
+
body = {:foo => "bar", :bar => "foo"}
|
103
|
+
|
104
|
+
response = meli.put("/items/123", body, params)
|
105
|
+
```
|
106
|
+
|
107
|
+
#### Making DELETE calls
|
108
|
+
```ruby
|
109
|
+
params = {:access_token => meli.access_token}
|
110
|
+
response = meli.delete("/questions/123", params)
|
111
|
+
```
|
112
|
+
|
113
|
+
## Examples
|
114
|
+
|
115
|
+
Don't forget to check out our examples codes in the folder [examples](https://github.com/mercadolibre/ruby-sdk/tree/master/examples)
|
116
|
+
|
117
|
+
[GET simple example console program](https://github.com/AlfredoBejarano/MercadoLibre-Ruby-SDK-Example)
|
118
|
+
|
119
|
+
[Ruby on Rails GET example](https://github.com/AlfredoBejarano/MercadoLibre-Ruby-SDK-Example-Rails-Edition)
|
120
|
+
|
121
|
+
## Community
|
122
|
+
|
123
|
+
You can contact us if you have questions using the standard communication channels described in the [developer's site](http://developers.mercadolibre.com/community/)
|
124
|
+
|
125
|
+
## I want to contribute!
|
126
|
+
|
127
|
+
That is great! Just fork the project in github. Create a topic branch, write some code, and add some tests for your new code.
|
128
|
+
|
129
|
+
Thanks for helping!
|
data/Rakefile
ADDED
data/examples/delete.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler/setup'
|
5
|
+
require 'meli'
|
6
|
+
require 'json'
|
7
|
+
|
8
|
+
meli = Meli.new(CLIENT_ID, CLIENT_SECRET, ACCESS_TOKEN, REFRESH_TOKEN)
|
9
|
+
|
10
|
+
response = meli.delete(
|
11
|
+
'/questions/QUESTION_ID',
|
12
|
+
access_token: meli.access_token
|
13
|
+
)
|
14
|
+
|
15
|
+
# Json format
|
16
|
+
puts response.body
|
17
|
+
|
18
|
+
# ruby hash format
|
19
|
+
res = JSON.parse response.body
|
20
|
+
puts res.inspect
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler/setup'
|
3
|
+
require 'meli'
|
4
|
+
require 'sinatra'
|
5
|
+
require 'json'
|
6
|
+
|
7
|
+
set :meli, Meli.new(CLIENT_ID, CLIENT_SECRET, ACCESS_TOKEN, REFRESH_TOKEN)
|
8
|
+
disable :reload
|
9
|
+
|
10
|
+
get '/authorize' do
|
11
|
+
content_type :text
|
12
|
+
settings.meli.authorize(params['code'], CALLBACK_URI) if params['code']
|
13
|
+
# Don't Forget to Save this data!
|
14
|
+
"SUCESS! Token:
|
15
|
+
#{settings.meli.access_token}
|
16
|
+
RefresToken: #{settings.meli.refresh_token}"
|
17
|
+
end
|
18
|
+
|
19
|
+
get '/login' do
|
20
|
+
"<a href='#{settings.meli.auth_url(CALLBACK_AUTHORIZE)}'>Login</a>"
|
21
|
+
end
|
data/examples/get.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler/setup'
|
5
|
+
require 'meli'
|
6
|
+
require 'json'
|
7
|
+
|
8
|
+
meli = Meli.new(CLIENT_ID, CLIENT_SECRET, ACCESS_TOKEN, REFRESH_TOKEN)
|
9
|
+
|
10
|
+
response = meli.get('/items/MLB488622999')
|
11
|
+
|
12
|
+
# Json format
|
13
|
+
puts response.body
|
14
|
+
|
15
|
+
# ruby hash format
|
16
|
+
res = JSON.parse response.body
|
17
|
+
puts res.inspect
|
data/examples/post.rb
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler/setup'
|
5
|
+
require 'meli'
|
6
|
+
|
7
|
+
meli = Meli.new(CLIENT_ID, CLIENT_SECRET, ACCESS_TOKEN, REFRESH_TOKEN)
|
8
|
+
|
9
|
+
body = {
|
10
|
+
'condition' => 'new',
|
11
|
+
'warranty' => '60 dias',
|
12
|
+
'currency_id' => 'BRL',
|
13
|
+
'accepts_mercadopago' => true,
|
14
|
+
'description' => 'Lindo Ray_Ban_Original_Wayfarer',
|
15
|
+
'listing_type_id' => 'bronze',
|
16
|
+
'title' =>
|
17
|
+
"\303\223culos Ray Ban Aviador Que Troca As Lentes Lan\303\247amento!",
|
18
|
+
'available_quantity' => 64,
|
19
|
+
'price' => 289,
|
20
|
+
'subtitle' => 'Acompanha 3 Pares De Lentes!! Compra 100% Segura',
|
21
|
+
'buying_mode' => 'buy_it_now',
|
22
|
+
'category_id' => 'MLB5125',
|
23
|
+
'pictures' => [
|
24
|
+
{
|
25
|
+
'source' =>
|
26
|
+
'http://upload.wikimedia.org/wikipedia/commons/f/fd/Ray_Ban_Original_Wayfarer.jpg'
|
27
|
+
},
|
28
|
+
{ 'source' =>
|
29
|
+
'http://en.wikipedia.org/wiki/File:Teashades.gif'
|
30
|
+
}
|
31
|
+
]
|
32
|
+
}
|
33
|
+
|
34
|
+
response = meli.post('/items', body, access_token: meli.access_token)
|
35
|
+
|
36
|
+
# Json format
|
37
|
+
puts response.body
|
38
|
+
|
39
|
+
# ruby hash format
|
40
|
+
res = JSON.parse response.body
|
41
|
+
puts res.inspect
|
data/examples/put.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'rubygems'
|
5
|
+
require 'meli'
|
6
|
+
|
7
|
+
meli = Meli.new(CLIENT_ID, CLIENT_SECRET, ACCESS_TOKEN, REFRESH_TOKEN)
|
8
|
+
|
9
|
+
body = { 'title' => 'New Title', 'price' => 1000 }
|
10
|
+
|
11
|
+
response = meli.put("/items/#{ITEM_ID}", body, access_token: meli.access_token)
|
12
|
+
|
13
|
+
# Json format
|
14
|
+
puts response.body
|
15
|
+
|
16
|
+
# ruby hash format
|
17
|
+
res = JSON.parse response.body
|
18
|
+
puts res.inspect
|
data/lib/config.yml
CHANGED
@@ -1,5 +1,21 @@
|
|
1
1
|
config:
|
2
|
-
sdk_version: MELI-RUBY-SDK-1.0.
|
2
|
+
sdk_version: MELI-RUBY-SDK-1.0.1
|
3
3
|
api_root_url: https://api.mercadolibre.com
|
4
|
-
auth_url: https://auth.
|
4
|
+
auth_url: https://auth.mercadolivre.com.br/authorization # # Don't forget to set the URL of your country.
|
5
5
|
oauth_url: /oauth/token
|
6
|
+
|
7
|
+
# Set the auth_url according to your country
|
8
|
+
|
9
|
+
#MLA https://auth.mercadolibre.com.ar/authorization # Argentina
|
10
|
+
#MLB https://auth.mercadolivre.com.br/authorization # Brasil
|
11
|
+
#MCO https://auth.mercadolibre.com.co/authorization # Colombia
|
12
|
+
#MCR https://auth.mercadolibre.com.cr/authorization # Costa Rica
|
13
|
+
#MEC https://auth.mercadolibre.com.ec/authorization # Ecuador
|
14
|
+
#MLC https://auth.mercadolibre.com.cl/authorization # Chile
|
15
|
+
#MLM https://auth.mercadolibre.com.mx/authorization # Mexico
|
16
|
+
#MLU https://auth.mercadolibre.com.uy/authorization # Uruguay
|
17
|
+
#MLV https://auth.mercadolibre.com.ve/authorization # Venezuela
|
18
|
+
#MPA https://auth.mercadolibre.com.pa/authorization # Panama
|
19
|
+
#MPE https://auth.mercadolibre.com.pe/authorization # Peru
|
20
|
+
#MPT https://auth.mercadolibre.com.pt/authorization # Prtugal
|
21
|
+
#MRD https://auth.mercadolibre.com.do/authorization # Dominicana
|
data/meli.gemspec
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = 'meli'
|
7
|
+
spec.version = '1.0.3.2'
|
8
|
+
spec.date = '2016-04-11'
|
9
|
+
spec.summary = 'meli'
|
10
|
+
spec.description = 'Gem for accesing MercadoLibre API'
|
11
|
+
spec.authors = ['Alfredo Bejarano']
|
12
|
+
spec.email = 'alfredo.corona@mercadolibre.com.mx'
|
13
|
+
spec.files = Dir['lib/**/*.rb', 'lib/**/*.yml']
|
14
|
+
spec.homepage = 'http://developers.mercadolibre.com/ruby-sdk/'
|
15
|
+
spec.license = 'MIT'
|
16
|
+
spec.required_ruby_version = '>= 2.2'
|
17
|
+
spec.summary = "MercadoLibre's Ruby SDK"
|
18
|
+
spec.description = "Gem for using MercadoLibre's resources in your Ruby app"
|
19
|
+
spec.homepage = 'http://developers.mercadolibre.com'
|
20
|
+
spec.license = 'MIT'
|
21
|
+
|
22
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
23
|
+
spec.bindir = 'exe'
|
24
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
25
|
+
spec.require_paths = ['lib']
|
26
|
+
|
27
|
+
spec.add_development_dependency 'bundler', '~> 1.8'
|
28
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
29
|
+
end
|
metadata
CHANGED
@@ -1,24 +1,65 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: meli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.3.
|
4
|
+
version: 1.0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alfredo Bejarano
|
8
8
|
autorequire:
|
9
|
-
bindir:
|
9
|
+
bindir: exe
|
10
10
|
cert_chain: []
|
11
11
|
date: 2016-04-11 00:00:00.000000000 Z
|
12
|
-
dependencies:
|
13
|
-
|
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.8'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.8'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
description: Gem for using MercadoLibre's resources in your Ruby app
|
14
42
|
email: alfredo.corona@mercadolibre.com.mx
|
15
43
|
executables: []
|
16
44
|
extensions: []
|
17
45
|
extra_rdoc_files: []
|
18
46
|
files:
|
47
|
+
- ".gitignore"
|
48
|
+
- ".rubocop.yml"
|
49
|
+
- ".travis.yml"
|
50
|
+
- Gemfile
|
51
|
+
- Gemfile.lock
|
52
|
+
- README.md
|
53
|
+
- Rakefile
|
54
|
+
- examples/delete.rb
|
55
|
+
- examples/example_login.rb
|
56
|
+
- examples/get.rb
|
57
|
+
- examples/post.rb
|
58
|
+
- examples/put.rb
|
19
59
|
- lib/config.yml
|
20
60
|
- lib/meli.rb
|
21
|
-
|
61
|
+
- meli.gemspec
|
62
|
+
homepage: http://developers.mercadolibre.com
|
22
63
|
licenses:
|
23
64
|
- MIT
|
24
65
|
metadata: {}
|
@@ -41,5 +82,5 @@ rubyforge_project:
|
|
41
82
|
rubygems_version: 2.6.2
|
42
83
|
signing_key:
|
43
84
|
specification_version: 4
|
44
|
-
summary:
|
85
|
+
summary: MercadoLibre's Ruby SDK
|
45
86
|
test_files: []
|