Module: Business::BR::Shipping
- Defined in:
- lib/business-br/shipping.rb,
lib/business-br/shipping/version.rb
Constant Summary collapse
- API_HOST =
ENV['API_HOST'] || 'https://api.postmon.com.br/v1/rastreio/'
- API_PROVIDER =
ENV['API_PROVIDER'] || 'ect'
- VERSION =
"0.1.0"
Class Method Summary collapse
Class Method Details
.tracking(shipping_code) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/business-br/shipping.rb', line 15 def tracking(shipping_code) return nil unless shipping_code response = HTTP.get("#{API_HOST}/#{API_PROVIDER}/#{shipping_code}") payload = JSON.parse(response.body.to_s) code, provider, activities = payload.values_at('codigo', 'servico', 'historico') { code: code, provider: provider, activities: activities_serializer(activities) } end |