Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: ecommerce-ventures/deliveries
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v0.2.0
Choose a base ref
...
head repository: ecommerce-ventures/deliveries
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
  • 14 commits
  • 22 files changed
  • 8 contributors

Commits on Nov 4, 2021

  1. Copy the full SHA
    4b0a2f2 View commit details
  2. Version bump to 0.2.1

    raulr committed Nov 4, 2021
    Copy the full SHA
    3144135 View commit details

Commits on Nov 26, 2021

  1. Integrate envialia courier

    pdrowr authored Nov 26, 2021

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    4d7b362 View commit details
  2. Fix changelog

    raulr committed Nov 26, 2021
    Copy the full SHA
    a49a814 View commit details
  3. Copy the full SHA
    45792d3 View commit details
  4. Version bump to 0.3.0

    raulr committed Nov 26, 2021
    Copy the full SHA
    39817c2 View commit details

Commits on Jan 12, 2023

  1. Fix inpost week hours (#5)

    pellytw authored Jan 12, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    aef8f04 View commit details

Commits on Jan 13, 2023

  1. Version bump to 0.3.1

    franvegar committed Jan 13, 2023
    Copy the full SHA
    ffd7fb6 View commit details

Commits on Sep 14, 2023

  1. Copy the full SHA
    85321ad View commit details
  2. Version bump to 0.3.2

    franvegar authored and circunspecter committed Sep 14, 2023
    Copy the full SHA
    bcad935 View commit details

Commits on Mar 22, 2024

  1. Prefix delivery location with country code in Mondial Relay Dual (#7)

    circunspecter authored Mar 22, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    1445c2a View commit details
  2. Version bump to 0.3.3

    circunspecter committed Mar 22, 2024
    Copy the full SHA
    0ce212f View commit details

Commits on Nov 29, 2024

  1. Set default weight to one for Envialia shipping labels (#8)

    * Set default weight to one for Envialia shipping labels
    
    * Set default weight to one for Envialia shipping labels
    drodriguezgood authored Nov 29, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    e711e8e View commit details

Commits on Dec 5, 2024

  1. Version bump to 0.3.4

    franvegar committed Dec 5, 2024
    Copy the full SHA
    2267aa4 View commit details
34 changes: 32 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -6,6 +6,30 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.3.4] - 2024-12-05
### Fixed
- Set default weight to one for Envialia shipping labels.

## [0.3.3] - 2024-03-22
### Fixed
- Prefix delivery location with country code in Mondial Relay Dual.

## [0.3.2] - 2023-09-14
### Fixed
- Add follow_redirect to MondialRelay module API call

## [0.3.1] - 2023-01-13
### Fixed
- Inpost week hours

## [0.3.0] - 2021-11-26
### Added
- Envialia courier integration

## [0.2.1] - 2021-11-04
### Fixed
- Field `clienteRecogida` must have the same value as `codDest` in Correos Express pickup.

## [0.2.0] - 2021-11-03
### Added
- `Address` can now include a custom id for couriers that support it (currently only Correos Express).
@@ -17,7 +41,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [0.1.0] - 2021-09-27
🎉 First release!

[Unreleased]: https://github.com/ecommerce-ventures/deliveries/compare/v0.2.0...HEAD
[Unreleased]: https://github.com/ecommerce-ventures/deliveries/compare/v0.3.4...HEAD
[0.3.4]: https://github.com/ecommerce-ventures/deliveries/compare/v0.3.3...v0.3.4
[0.3.3]: https://github.com/ecommerce-ventures/deliveries/compare/v0.3.2...v0.3.3
[0.3.2]: https://github.com/ecommerce-ventures/deliveries/compare/v0.3.1...v0.3.2
[0.3.1]: https://github.com/ecommerce-ventures/deliveries/compare/v0.3.0...v0.3.1
[0.3.0]: https://github.com/ecommerce-ventures/deliveries/compare/v0.2.1...v0.3.0
[0.2.1]: https://github.com/ecommerce-ventures/deliveries/compare/v0.2.0...v0.2.1
[0.2.0]: https://github.com/ecommerce-ventures/deliveries/compare/v0.1.1...v0.2.0
[0.1.1]: https://github.com/ecommerce-ventures/deliveries/compare/v0.1.0...v0.1.1
[0.1.0]: https://github.com/ecommerce-ventures/deliveries/releases/tag/v0.1.0
[0.1.0]: https://github.com/ecommerce-ventures/deliveries/releases/tag/v0.1.0
75 changes: 47 additions & 28 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
deliveries (0.2.0)
deliveries (0.3.4)
activesupport (>= 5.2.0)
hexapdf
httparty
@@ -12,7 +12,7 @@ PATH
GEM
remote: https://rubygems.org/
specs:
activesupport (6.1.4.1)
activesupport (6.1.7.7)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 1.6, < 2)
minitest (>= 5.1)
@@ -27,40 +27,57 @@ GEM
builder (3.2.4)
byebug (11.1.3)
cmdparse (3.0.7)
concurrent-ruby (1.1.9)
concurrent-ruby (1.2.3)
crack (0.4.5)
rexml
date (3.3.4)
diff-lcs (1.4.4)
geom2d (0.3.1)
gyoku (1.3.1)
geom2d (0.4.1)
gyoku (1.4.0)
builder (>= 2.1.2)
rexml (~> 3.0)
hashdiff (1.0.1)
hexapdf (0.17.3)
hexapdf (0.36.0)
cmdparse (~> 3.0, >= 3.0.3)
geom2d (~> 0.3)
httparty (0.20.0)
mime-types (~> 3.0)
geom2d (~> 0.4, >= 0.4.1)
openssl (>= 2.2.1)
httparty (0.21.0)
mini_mime (>= 1.0.0)
multi_xml (>= 0.5.2)
httpi (2.5.0)
httpi (3.0.1)
rack
socksify
i18n (1.8.11)
i18n (1.14.4)
concurrent-ruby (~> 1.0)
mime-types (3.3.1)
mime-types-data (~> 3.2015)
mime-types-data (3.2021.0901)
mini_magick (4.11.0)
minitest (5.14.4)
mail (2.8.1)
mini_mime (>= 0.1.1)
net-imap
net-pop
net-smtp
mini_magick (4.12.0)
mini_mime (1.1.5)
mini_portile2 (2.8.8)
minitest (5.22.3)
multi_xml (0.6.0)
nokogiri (1.12.5-x86_64-linux)
net-imap (0.3.7)
date
net-protocol
net-pop (0.1.2)
net-protocol
net-protocol (0.2.2)
timeout
net-smtp (0.4.0.1)
net-protocol
nokogiri (1.13.10)
mini_portile2 (~> 2.8.0)
racc (~> 1.4)
nori (2.6.0)
openssl (3.1.0)
parallel (1.21.0)
parser (3.0.2.0)
ast (~> 2.4.1)
public_suffix (4.0.6)
racc (1.6.0)
rack (2.2.3)
racc (1.7.3)
rack (3.0.10)
rainbow (3.0.0)
rake (13.0.6)
regexp_parser (2.1.1)
@@ -90,29 +107,31 @@ GEM
rubocop-ast (1.12.0)
parser (>= 3.0.1.1)
ruby-progressbar (1.11.0)
savon (2.12.1)
savon (2.13.0)
akami (~> 1.2)
builder (>= 2.1.2)
gyoku (~> 1.2)
httpi (~> 2.3)
httpi (>= 2.4.5)
mail (~> 2.5)
nokogiri (>= 1.8.1)
nori (~> 2.4)
wasabi (~> 3.4)
socksify (1.7.1)
tzinfo (2.0.4)
timeout (0.4.1)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
unicode-display_width (1.8.0)
wasabi (3.6.1)
wasabi (3.8.0)
addressable
httpi (~> 2.0)
httpi (~> 3.0)
nokogiri (>= 1.4.2)
webmock (3.14.0)
webmock (3.19.1)
addressable (>= 2.8.0)
crack (>= 0.3.2)
hashdiff (>= 0.4.0, < 2.0.0)
zeitwerk (2.5.1)
zeitwerk (2.6.13)

PLATFORMS
ruby
x86_64-linux

DEPENDENCIES
33 changes: 22 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@ Deliveries is a gem that gives you the ability to integrate multiple shipping se

Add the following line to your Gemfile

```bash
```ruby
gem 'deliveries'
```
Then run:
@@ -20,15 +20,15 @@ bundle install
Each courier requires a different configuration, below we will leave some examples

#### 1. Mondial Relay
```bash
```ruby
Deliveries.courier(:mondial_relay).configure do |config|
config.mondial_relay_merchant = '...'
config.mondial_relay_key = '...'
end
```

#### 2. Mondial Relay Dual
```bash
```ruby
Deliveries.courier(:mondial_relay_dual).configure do |config|
config.dual_carrier_login = '...'
config.dual_carrier_password = '...'
@@ -48,7 +48,7 @@ end
```

#### 3. Correos Express
```bash
```ruby
Deliveries.courier(:correos_express).configure do |config|
config.username = '...'
config.password = '...'
@@ -67,7 +67,7 @@ end
```

#### 4. Spring
```bash
```ruby
Deliveries.courier(:spring).configure do |config|
config.api_key = '...'
config.countries = {
@@ -89,7 +89,7 @@ end
```

#### 5. UPS
```bash
```ruby
Deliveries.courier(:ups).configure do |config|
config.license_number = '...'
config.username = '...'
@@ -103,25 +103,36 @@ Deliveries.courier(:ups).configure do |config|
end
```

#### Time Zone

This library uses Active Support's Time extension, so a time zone must be set before using it:

```ruby
require 'active_support/time'

# Configure time zone
Time.zone = 'Madrid'
```

## Usage

#### Get collection point by country and postcode

```bash
```ruby
# Example Using Ups

Deliveries.courier(:ups).get_collection_points(postcode: '...', country: 'it')
```
#### Get collection point info

```bash
```ruby
# Example Using Mondial Relay

Deliveries.courier(:mondial_relay).get_collection_point(global_point_id: 'mondial_relay~fr~00000~XXXXXX')
```

#### Create a Shipment
```bash
```ruby
# Example Using Correos Express

sender = Deliveries::Address.new(
@@ -158,7 +169,7 @@ response = Deliveries.courier(:correos_express).create_shipment(
```

#### Create a Pickup
```bash
```ruby
# Example Using Spring

sender = Deliveries::Address.new(
@@ -193,7 +204,7 @@ response = Deliveries.courier(:spring).create_pickup(
```

#### Download a Label
```bash
```ruby
# Example Using Spring

label = Deliveries.courier(:spring).get_label(tracking_code: '...')
Original file line number Diff line number Diff line change
@@ -24,7 +24,7 @@ def execute
solicitante: CorreosExpress.config(:client_code),
refRecogida: reference_code,
fechaRecogida: pickup_date&.strftime('%d%m%Y') || '',
clienteRecogida: CorreosExpress.config(:pickup_receiver_code),
clienteRecogida: receiver.address_id || CorreosExpress.config(:pickup_receiver_code),
codRemit: sender.address_id || '',
nomRemit: sender.name,
nifRemit: '',
93 changes: 93 additions & 0 deletions lib/deliveries/couriers/envialia.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
require_relative 'envialia/authentication'
require_relative 'envialia/shipments/create'
require_relative 'envialia/shipments/trace/format_response'
require_relative 'envialia/shipments/trace'
require_relative 'envialia/pickups/trace/format_response'
require_relative 'envialia/pickups/trace'
require_relative 'envialia/pickups/create'
require_relative 'envialia/labels/generate'

module Deliveries
module Couriers
module Envialia
extend Courier

Config = Struct.new(
:username,
:password,
:agency_code
)

ENVIALIA_LOGIN_ENDPOINT_LIVE = 'http://ws.envialia.com/SOAP?service=LoginService'.freeze
ENVIALIA_LOGIN_ENDPOINT_TEST = 'http://wstest.envialia.com:9085/SOAP?service=LoginService'.freeze
ENVIALIA_ENDPOINT_LIVE = 'http://ws.envialia.com/SOAP?service=WebServService'.freeze
ENVIALIA_ENDPOINT_TEST = 'http://wstest.envialia.com:9085/SOAP?service=WebServService'.freeze

module_function

def create_shipment(sender:, receiver:, parcels:, reference_code:, collection_point: nil, shipment_date: nil, remarks: nil, **)
Shipments::Create.new(
sender: sender,
receiver: receiver,
collection_point: collection_point,
shipment_date: shipment_date,
parcels: parcels,
reference_code: reference_code,
remarks: remarks
).execute
end

def create_pickup(sender:, receiver:, parcels:, reference_code:, pickup_date: nil, remarks: nil, tracking_code: nil, **)
Pickups::Create.new(
sender: sender,
receiver: receiver,
parcels: parcels,
reference_code: reference_code,
pickup_date: pickup_date,
remarks: remarks,
tracking_code: tracking_code
).execute
end

def shipment_info(tracking_code:, **)
response = Shipments::Trace.new(
tracking_code: tracking_code
).execute

tracking_info_params = Shipments::Trace::FormatResponse.new(response: response).execute
tracking_info_params.merge!({ tracking_code: tracking_code })
Deliveries::TrackingInfo.new(**tracking_info_params)
end

def pickup_info(tracking_code:, **)
response = Pickups::Trace.new(
tracking_code: tracking_code
).execute

tracking_info_params = Pickups::Trace::FormatResponse.new(response: response).execute
tracking_info_params.merge!({ tracking_code: tracking_code })
Deliveries::TrackingInfo.new(**tracking_info_params)
end

def get_label(tracking_code:, **)
pdf = Labels::Generate.new(
tracking_codes: tracking_code
).execute.first

Deliveries::Label.new(raw: pdf)
end

def get_labels(tracking_codes:, **)
labels = Deliveries::Labels.new

Labels::Generate.new(
tracking_codes: tracking_codes
).execute.each do |pdf|
labels << pdf
end

labels
end
end
end
end
Loading