Project

envia_ya

0.0
The project is in a healthy, maintained state
Ruby implementation of EnviaYa! shipping service.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
 Dependencies
 Project Readme

EnviaYa Ruby Gem

Setup

You can install the gem manually

gem install envia_ya

or add it to your Gemfile and use Bundler for installation.

gem 'envia_ya'

Usage

Set API KEY

First you have to set your API KEY to have access to EnviaYa! API.

EnviaYa::Config.api_key = YOUR_API_KEY

Rates

Rate Shipment

repository = EnviaYa::Rates::Infrastructure::Repositories::RatesHttpRepository.new
command = EnviaYa::Rates::Application::Commands::CreateRateCommand.new(repository: repository)
dto = EnviaYa::Rates::Domain::Dtos::CreateRateDto.new(
  origin_direction: EnviaYa::Rates::Domain::Entities::DirectionEntity.new(
    postal_code: EnviaYa::Shared::Domain::ValueObjects::PostalCodeValueObject.new('68050'),
    country_code: 'MX'
  ),
  destination_direction: EnviaYa::Rates::Domain::Entities::DirectionEntity.new(
    postal_code: EnviaYa::Shared::Domain::ValueObjects::PostalCodeValueObject.new('68000'),
    country_code: 'MX'
  ),
  shipment: EnviaYa::Rates::Domain::Entities::ShipmentEntity.new(
    shipment_type: EnviaYa::Shared::Domain::ValueObjects::ShipmentTypeValueObject.new('Package'),
    parcels: [
      EnviaYa::Shared::Domain::Entities::ParcelEntity.new(
        quantity: 1,
        weight: 1.0,
        weight_unit: EnviaYa::Shared::Domain::ValueObjects::WeightUnitValueObject.new('kg'),
        height: 10.0,
        length: 10.0,
        width: 10.0,
        dimension_unit: EnviaYa::Shared::Domain::ValueObjects::DimensionUnitValueObject.new('cm')
      )
    ]
  )
)
command.execute(dto)