Module: Mercadolibre::Core::LocationsAndCurrencies

Included in:
Api
Defined in:
lib/mercadolibre/core/locations_and_currencies.rb

Instance Method Summary collapse

Instance Method Details

#currency_convertion_rate(currency_from, currency_to) ⇒ Object


40
41
42
43
44
45
46
47
48
49
50
# File 'lib/mercadolibre/core/locations_and_currencies.rb', line 40

def currency_convertion_rate(currency_from, currency_to)
  filters = { from: currency_from, to: currency_to }
  result = get_request('/currency_conversions/search', filters)

  Mercadolibre::Entity::Currency.new({
    currency_from: currency_from,
    currency_to: currency_to,
    ratio: result[:body]['ratio'],
    mercado_pago_ratio: result[:body]['mercado_pago_ratio']
  })
end

#get_city(city_id) ⇒ Object


22
23
24
25
26
# File 'lib/mercadolibre/core/locations_and_currencies.rb', line 22

def get_city(city_id)
  result = get_request("/cities/#{city_id}")

  Mercadolibre::Entity::City.new(result[:body])
end

#get_countriesObject


4
5
6
7
8
# File 'lib/mercadolibre/core/locations_and_currencies.rb', line 4

def get_countries
  results = get_request('/countries')

  results[:body].map { |r| Mercadolibre::Entity::Country.new(r) }
end

#get_country(country_id) ⇒ Object


10
11
12
13
14
# File 'lib/mercadolibre/core/locations_and_currencies.rb', line 10

def get_country(country_id)
  result = get_request("/countries/#{country_id}")

  Mercadolibre::Entity::Country.new(result[:body])
end

#get_currenciesObject


28
29
30
31
32
# File 'lib/mercadolibre/core/locations_and_currencies.rb', line 28

def get_currencies
  results = get_request('/currencies')

  results[:body].map { |r| Mercadolibre::Entity::Currency.new(r) }
end

#get_currency(currency_id) ⇒ Object


34
35
36
37
38
# File 'lib/mercadolibre/core/locations_and_currencies.rb', line 34

def get_currency(currency_id)
  result = get_request("/currencies/#{currency_id}")

  Mercadolibre::Entity::Currency.new(result[:body])
end

#get_state(state_id) ⇒ Object


16
17
18
19
20
# File 'lib/mercadolibre/core/locations_and_currencies.rb', line 16

def get_state(state_id)
  result = get_request("/states/#{state_id}")

  Mercadolibre::Entity::State.new(result[:body])
end

#get_zip_code_info(country_id, zip_code) ⇒ Object


52
53
54
55
56
# File 'lib/mercadolibre/core/locations_and_currencies.rb', line 52

def get_zip_code_info(country_id, zip_code)
  result = get_request("/countries/#{country_id}/zip_codes/#{zip_code}")

  Mercadolibre::Entity::ZipCode.new(result[:body])
end