mercadolibre 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +1 -9
- data/lib/mercadolibre.rb +6 -0
- data/lib/mercadolibre/api.rb +1 -0
- data/lib/mercadolibre/core/locations.rb +53 -0
- data/lib/mercadolibre/entity/city.rb +27 -0
- data/lib/mercadolibre/entity/country.rb +26 -0
- data/lib/mercadolibre/entity/currency.rb +21 -0
- data/lib/mercadolibre/entity/currency_conversion_ratio.rb +21 -0
- data/lib/mercadolibre/entity/state.rb +27 -0
- data/lib/mercadolibre/version.rb +1 -1
- metadata +8 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 981ac206ea9f2d17f765be14e6c652b3b84ce142
|
4
|
+
data.tar.gz: ced98f838d44e8a5c123222fcc6348688bcdf25e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 67249600ddcd23a8d2d6ca4ee312292ce2a96d128008f25d00a645cf21b53c02046a18e2acb373ca71219b8ad468c7870e71ca265a9563fc3505cd69b16866f6
|
7
|
+
data.tar.gz: 7a3f5378a140d277fe6c931e57d0fc2cec4e7c3c5b626ab374ec0d4384f5dfffa3379188444e40c099ce36ef596571acd3f1f84864324ba7394d266802941cdf
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Mercadolibre
|
2
2
|
|
3
|
-
|
3
|
+
Implementation of meli API to access MercadoLibre
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
@@ -19,11 +19,3 @@ Or install it yourself as:
|
|
19
19
|
## Usage
|
20
20
|
|
21
21
|
TODO: Write usage instructions here
|
22
|
-
|
23
|
-
## Contributing
|
24
|
-
|
25
|
-
1. Fork it ( http://github.com/<my-github-username>/mercadolibre/fork )
|
26
|
-
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
-
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
-
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
-
5. Create new Pull Request
|
data/lib/mercadolibre.rb
CHANGED
@@ -3,6 +3,10 @@ require "mercadolibre/version"
|
|
3
3
|
# entities
|
4
4
|
require "mercadolibre/entity/answer"
|
5
5
|
require "mercadolibre/entity/auth"
|
6
|
+
require "mercadolibre/entity/city"
|
7
|
+
require "mercadolibre/entity/country"
|
8
|
+
require "mercadolibre/entity/currency"
|
9
|
+
require "mercadolibre/entity/currency_conversion_ratio"
|
6
10
|
require "mercadolibre/entity/feedback"
|
7
11
|
require "mercadolibre/entity/item"
|
8
12
|
require "mercadolibre/entity/item_picture"
|
@@ -11,10 +15,12 @@ require "mercadolibre/entity/order_item"
|
|
11
15
|
require "mercadolibre/entity/payment"
|
12
16
|
require "mercadolibre/entity/phone"
|
13
17
|
require "mercadolibre/entity/question"
|
18
|
+
require "mercadolibre/entity/state"
|
14
19
|
require "mercadolibre/entity/user"
|
15
20
|
# core
|
16
21
|
require "mercadolibre/core/auth"
|
17
22
|
require "mercadolibre/core/items"
|
23
|
+
require "mercadolibre/core/locations"
|
18
24
|
require "mercadolibre/core/orders"
|
19
25
|
require "mercadolibre/core/questions"
|
20
26
|
require "mercadolibre/core/users"
|
data/lib/mercadolibre/api.rb
CHANGED
@@ -0,0 +1,53 @@
|
|
1
|
+
module Mercadolibre
|
2
|
+
module Core
|
3
|
+
module Locations
|
4
|
+
def get_countries
|
5
|
+
results = get_request('/countries')
|
6
|
+
|
7
|
+
results[:body].map { |r| Mercadolibre::Entity::Country.new(r) }
|
8
|
+
end
|
9
|
+
|
10
|
+
def get_country(country_id)
|
11
|
+
result = get_request("/countries/#{country_id}")
|
12
|
+
|
13
|
+
Mercadolibre::Entity::Country.new(result[:body])
|
14
|
+
end
|
15
|
+
|
16
|
+
def get_state(state_id)
|
17
|
+
result = get_request("/states/#{state_id}")
|
18
|
+
|
19
|
+
Mercadolibre::Entity::State.new(result[:body])
|
20
|
+
end
|
21
|
+
|
22
|
+
def get_city(city_id)
|
23
|
+
result = get_request("/cities/#{city_id}")
|
24
|
+
|
25
|
+
Mercadolibre::Entity::City.new(result[:body])
|
26
|
+
end
|
27
|
+
|
28
|
+
def get_currencies
|
29
|
+
results = get_request('/currencies')
|
30
|
+
|
31
|
+
results[:body].map { |r| Mercadolibre::Entity::Currency.new(r) }
|
32
|
+
end
|
33
|
+
|
34
|
+
def get_currency(currency_id)
|
35
|
+
result = get_request("/currencies/#{currency_id}")
|
36
|
+
|
37
|
+
Mercadolibre::Entity::Currency.new(result[:body])
|
38
|
+
end
|
39
|
+
|
40
|
+
def currency_convertion_rate(currency_from, currency_to)
|
41
|
+
filters = { from: currency_from, to: currency_to }
|
42
|
+
result = get_request('/currency_conversions/search', filters)
|
43
|
+
|
44
|
+
Mercadolibre::Entity::Currency.new({
|
45
|
+
currency_from: currency_from,
|
46
|
+
currency_to: currency_to,
|
47
|
+
ratio: result[:body]['ratio'],
|
48
|
+
mercado_pago_ratio: result[:body]['mercado_pago_ratio']
|
49
|
+
})
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Mercadolibre
|
2
|
+
module Entity
|
3
|
+
class City
|
4
|
+
def self.attr_list
|
5
|
+
[:id, :name, :state, :country]
|
6
|
+
end
|
7
|
+
|
8
|
+
attr_reader *attr_list
|
9
|
+
|
10
|
+
def initialize(attributes={})
|
11
|
+
attributes.each do |k, v|
|
12
|
+
if k.to_s == 'state'
|
13
|
+
self.state = State.new(v)
|
14
|
+
elsif k.to_s == 'country'
|
15
|
+
self.country = Country.new(v)
|
16
|
+
else
|
17
|
+
self.send("#{k}=", v) if self.respond_to?(k)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
attr_writer *attr_list
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Mercadolibre
|
2
|
+
module Entity
|
3
|
+
class Country
|
4
|
+
def self.attr_list
|
5
|
+
[:id, :name, :locale, :currency_id, :decimal_separator,
|
6
|
+
:thousands_separator, :time_zone, :states]
|
7
|
+
end
|
8
|
+
|
9
|
+
attr_reader *attr_list
|
10
|
+
|
11
|
+
def initialize(attributes={})
|
12
|
+
attributes.each do |k, v|
|
13
|
+
if k.to_s == 'states'
|
14
|
+
self.states = v.map { |x| State.new(x) }
|
15
|
+
else
|
16
|
+
self.send("#{k}=", v) if self.respond_to?(k)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
attr_writer *attr_list
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Mercadolibre
|
2
|
+
module Entity
|
3
|
+
class Currency
|
4
|
+
def self.attr_list
|
5
|
+
[:id, :description, :symbol, :decimal_places]
|
6
|
+
end
|
7
|
+
|
8
|
+
attr_reader *attr_list
|
9
|
+
|
10
|
+
def initialize(attributes={})
|
11
|
+
attributes.each do |k, v|
|
12
|
+
self.send("#{k}=", v) if self.respond_to?(k)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
attr_writer *attr_list
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Mercadolibre
|
2
|
+
module Entity
|
3
|
+
class CurrencyConversionRatio
|
4
|
+
def self.attr_list
|
5
|
+
[:currency_from, :currency_to, :currency_id, :ratio, :mercado_pago_ratio]
|
6
|
+
end
|
7
|
+
|
8
|
+
attr_reader *attr_list
|
9
|
+
|
10
|
+
def initialize(attributes={})
|
11
|
+
attributes.each do |k, v|
|
12
|
+
self.send("#{k}=", v) if self.respond_to?(k)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
attr_writer *attr_list
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Mercadolibre
|
2
|
+
module Entity
|
3
|
+
class State
|
4
|
+
def self.attr_list
|
5
|
+
[:id, :name, :country, :cities]
|
6
|
+
end
|
7
|
+
|
8
|
+
attr_reader *attr_list
|
9
|
+
|
10
|
+
def initialize(attributes={})
|
11
|
+
attributes.each do |k, v|
|
12
|
+
if k.to_s == 'cities'
|
13
|
+
self.cities = v.map { |x| City.new(x) }
|
14
|
+
elsif k.to_s == 'country'
|
15
|
+
self.country = Country.new(v)
|
16
|
+
else
|
17
|
+
self.send("#{k}=", v) if self.respond_to?(k)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
attr_writer *attr_list
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
data/lib/mercadolibre/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mercadolibre
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matias Hick
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-03-
|
11
|
+
date: 2014-03-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -66,11 +66,16 @@ files:
|
|
66
66
|
- lib/mercadolibre/api.rb
|
67
67
|
- lib/mercadolibre/core/auth.rb
|
68
68
|
- lib/mercadolibre/core/items.rb
|
69
|
+
- lib/mercadolibre/core/locations.rb
|
69
70
|
- lib/mercadolibre/core/orders.rb
|
70
71
|
- lib/mercadolibre/core/questions.rb
|
71
72
|
- lib/mercadolibre/core/users.rb
|
72
73
|
- lib/mercadolibre/entity/answer.rb
|
73
74
|
- lib/mercadolibre/entity/auth.rb
|
75
|
+
- lib/mercadolibre/entity/city.rb
|
76
|
+
- lib/mercadolibre/entity/country.rb
|
77
|
+
- lib/mercadolibre/entity/currency.rb
|
78
|
+
- lib/mercadolibre/entity/currency_conversion_ratio.rb
|
74
79
|
- lib/mercadolibre/entity/feedback.rb
|
75
80
|
- lib/mercadolibre/entity/item.rb
|
76
81
|
- lib/mercadolibre/entity/item_picture.rb
|
@@ -79,6 +84,7 @@ files:
|
|
79
84
|
- lib/mercadolibre/entity/payment.rb
|
80
85
|
- lib/mercadolibre/entity/phone.rb
|
81
86
|
- lib/mercadolibre/entity/question.rb
|
87
|
+
- lib/mercadolibre/entity/state.rb
|
82
88
|
- lib/mercadolibre/entity/user.rb
|
83
89
|
- lib/mercadolibre/version.rb
|
84
90
|
homepage: https://github.com/unformattmh/mercadolibre
|