envia_ya 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/envia_ya.rb +2 -0
- data/lib/modules/rates/domain/dtos/create_rate_dto.rb +7 -7
- data/lib/modules/{shared → rates}/domain/entities/direction_entity.rb +10 -10
- data/lib/modules/{shared → rates}/domain/entities/shipment_entity.rb +10 -12
- data/lib/modules/rates/infrastructure/repositories/create_rate_repository/create_rate_http_repository.rb +2 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4f34bde2b191a32b39727b9b4ea3bf2f57c754dd8233cd2556255cd4e677cee9
|
4
|
+
data.tar.gz: 1ce242532cabdd9c0abbd16eca0960331ea6e8b87d319c60383ebb0c842e5aad
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 07c425c77f612ff918874cb5821900173414450266df22f87fea95536f4f456ecc6379416f4ebc1c496412289b6b92e52675bd7ecfb3dcf306ca60cb970a8c25
|
7
|
+
data.tar.gz: 320feecef73e14775d195f8d46107cdbab3da13e9107472ed50f8dab0f0f3d4068dffb780cd4440201b0e7764deaf06ff621eafa95cc643a13381cb6c1ca5eb9
|
data/lib/envia_ya.rb
CHANGED
@@ -1,7 +1,9 @@
|
|
1
1
|
require 'singleton'
|
2
|
+
require_relative './modules/rates/infrastructure/repositories/create_rate_repository/create_rate_http_repository.rb'
|
2
3
|
require_relative './modules/rates/application/commands/create_rate_command.rb'
|
3
4
|
|
4
5
|
module EnviaYa
|
6
|
+
include Rates::Infrastructure::Repositories
|
5
7
|
include Rates::Application::Commands
|
6
8
|
|
7
9
|
class Config
|
@@ -1,6 +1,6 @@
|
|
1
|
-
require_relative '../../../shared/domain/entities/direction_entity.rb'
|
2
|
-
require_relative '../../../shared/domain/entities/shipment_entity.rb'
|
3
1
|
require_relative '../../../shared/domain/entities/accounts_entity.rb'
|
2
|
+
require_relative '../entities/direction_entity.rb'
|
3
|
+
require_relative '../entities/shipment_entity.rb'
|
4
4
|
|
5
5
|
module EnviaYa
|
6
6
|
module Rates
|
@@ -15,16 +15,16 @@ module EnviaYa
|
|
15
15
|
:intelligent_filtering
|
16
16
|
|
17
17
|
def initialize(
|
18
|
-
origin_direction
|
19
|
-
destination_direction
|
18
|
+
origin_direction:,
|
19
|
+
destination_direction:,
|
20
20
|
shipment:,
|
21
21
|
accounts: nil,
|
22
22
|
order_total_amount: nil,
|
23
23
|
intelligent_filtering: nil
|
24
24
|
)
|
25
|
-
raise TypeError, "origin_direction expected a DirectionEntity
|
26
|
-
raise TypeError, "destination_direction expected a DirectionEntity
|
27
|
-
raise TypeError, "shipment expected
|
25
|
+
raise TypeError, "origin_direction expected a DirectionEntity but got: #{origin_direction.class}" unless origin_direction.is_a?(::EnviaYa::Rates::Domain::Entities::DirectionEntity)
|
26
|
+
raise TypeError, "destination_direction expected a DirectionEntity but got: #{destination_direction.class}" unless destination_direction.is_a?(::EnviaYa::Rates::Domain::Entities::DirectionEntity)
|
27
|
+
raise TypeError, "shipment expected ShipmentEntity but got: #{shipment.class}" unless shipment.is_a?(::EnviaYa::Rates::Domain::Entities::ShipmentEntity)
|
28
28
|
raise TypeError, "accounts expected an AccountsEntity or NilClass but got: #{accounts.class}" unless accounts.is_a?(::EnviaYa::Shared::Domain::Entities::AccountsEntity) || accounts.is_a?(NilClass)
|
29
29
|
raise TypeError, "order_total_amount expected an Integer or NilClass but got: #{order_total_amount.class}" unless order_total_amount.is_a?(Integer) || order_total_amount.is_a?(NilClass)
|
30
30
|
raise TypeError, "intelligent_filtering expected a TrueClass, FalseClass or NilClass but got: #{intelligent_filtering.class}" unless intelligent_filtering.is_a?(TrueClass) || intelligent_filtering.is_a?(FalseClass) || intelligent_filtering.is_a?(NilClass)
|
@@ -1,7 +1,7 @@
|
|
1
|
-
require_relative '
|
1
|
+
require_relative '../../../shared/domain/value_objects/postal_code_value_object.rb'
|
2
2
|
|
3
3
|
module EnviaYa
|
4
|
-
module
|
4
|
+
module Rates
|
5
5
|
module Domain
|
6
6
|
module Entities
|
7
7
|
class DirectionEntity
|
@@ -19,30 +19,30 @@ module EnviaYa
|
|
19
19
|
:emai
|
20
20
|
|
21
21
|
def initialize(
|
22
|
-
full_name
|
22
|
+
full_name: nil,
|
23
23
|
company: nil,
|
24
|
-
direction_1
|
24
|
+
direction_1: nil,
|
25
25
|
direction_2: nil,
|
26
26
|
postal_code:,
|
27
27
|
neighborhood: nil,
|
28
28
|
district: nil,
|
29
|
-
city
|
29
|
+
city: nil,
|
30
30
|
state_code: nil,
|
31
31
|
country_code:,
|
32
|
-
phone
|
32
|
+
phone: nil,
|
33
33
|
email: nil
|
34
34
|
)
|
35
|
-
raise TypeError, "full_name expected a String or NilClass but got: #{full_name.class}" unless full_name.is_a?(String)
|
35
|
+
raise TypeError, "full_name expected a String or NilClass but got: #{full_name.class}" unless full_name.is_a?(String) || full_name.is_a?(NilClass)
|
36
36
|
raise TypeError, "company expected a String or NilClass but got: #{company.class}" unless company.is_a?(String) || company.is_a?(NilClass)
|
37
|
-
raise TypeError, "direction_1 expected a String but got: #{direction_1.class}" unless direction_1.is_a?(String)
|
37
|
+
raise TypeError, "direction_1 expected a String or NilClass but got: #{direction_1.class}" unless direction_1.is_a?(String) || direction_1.is_a?(NilClass)
|
38
38
|
raise TypeError, "direction_1 expected a String or NilClass but got: #{direction_2.class}" unless direction_2.is_a?(String) || direction_2.is_a?(NilClass)
|
39
39
|
raise TypeError, "postal_code expected a PostalCodeValueObject but got: #{postal_code.class}" unless postal_code.is_a?(::EnviaYa::Shared::Domain::ValueObjects::PostalCodeValueObject)
|
40
40
|
raise TypeError, "neighborhood expected a String or NilClass but got: #{neighborhood.class}" unless neighborhood.is_a?(String) || neighborhood.is_a?(NilClass)
|
41
41
|
raise TypeError, "district expected a String or NilClass but got: #{district.class}" unless district.is_a?(String) || district.is_a?(NilClass)
|
42
|
-
raise TypeError, "city expected a String but got: #{city.class}" unless city.is_a?(String)
|
42
|
+
raise TypeError, "city expected a String or NilClass but got: #{city.class}" unless city.is_a?(String) || city.is_a?(NilClass)
|
43
43
|
raise TypeError, "state_code expected a String or NilClass but got: #{state_code.class}" unless state_code.is_a?(String) || state_code.is_a?(NilClass)
|
44
44
|
raise TypeError, "country_code expected a String but got: #{country_code.class}" unless country_code.is_a?(String)
|
45
|
-
raise TypeError, "phone expected a String but got: #{phone.class}" unless phone.is_a?(String)
|
45
|
+
raise TypeError, "phone expected a String or NilClass but got: #{phone.class}" unless phone.is_a?(String) || phone.is_a?(NilClass)
|
46
46
|
raise TypeError, "email expected a String or NilClass but got: #{email.class}" unless email.is_a?(String) || email.is_a?(NilClass)
|
47
47
|
|
48
48
|
@full_name = full_name
|
@@ -1,13 +1,13 @@
|
|
1
1
|
require 'date'
|
2
|
-
require_relative '
|
3
|
-
require_relative '
|
4
|
-
require_relative '
|
5
|
-
require_relative '
|
6
|
-
require_relative '
|
7
|
-
require_relative '
|
2
|
+
require_relative '../../../shared/domain/entities/parcel_entity.rb'
|
3
|
+
require_relative '../../../shared/domain/entities/rate_entity.rb'
|
4
|
+
require_relative '../../../shared/domain/entities/accounts_entity.rb'
|
5
|
+
require_relative '../../../shared/domain/value_objects/label_format_value_object.rb'
|
6
|
+
require_relative '../../../shared/domain/value_objects/label_file_type_value_object.rb'
|
7
|
+
require_relative '../../../shared/domain/value_objects/shipment_type_value_object.rb'
|
8
8
|
|
9
9
|
module EnviaYa
|
10
|
-
module
|
10
|
+
module Rates
|
11
11
|
module Domain
|
12
12
|
module Entities
|
13
13
|
class ShipmentEntity
|
@@ -30,7 +30,7 @@ module EnviaYa
|
|
30
30
|
:accounts
|
31
31
|
|
32
32
|
def initialize(
|
33
|
-
shipment_type
|
33
|
+
shipment_type:,
|
34
34
|
parcels:,
|
35
35
|
insured_value: nil,
|
36
36
|
insured_value_currency: nil,
|
@@ -48,11 +48,9 @@ module EnviaYa
|
|
48
48
|
rate: nil,
|
49
49
|
accounts: nil
|
50
50
|
)
|
51
|
-
unless shipment_type.is_a?(::EnviaYa::Shared::Domain::ValueObjects::ShipmentTypeValueObject)
|
52
|
-
raise TypeError, "shipment_type expected a ShipmentTypeValueObject but got: #{shipment_type.class}"
|
53
|
-
end
|
54
|
-
|
51
|
+
raise TypeError, "shipment_type expected a ShipmentTypeValueObject but got: #{shipment_type.class}" unless shipment_type.is_a?(::EnviaYa::Shared::Domain::ValueObjects::ShipmentTypeValueObject)
|
55
52
|
raise TypeError, "parcels expected an Array<ParcelEntity> but got: #{parcels.class}" unless parcels.is_a?(Array)
|
53
|
+
raise ArgumentError, 'parcels expected to have at least one element' if parcels.length.zero?
|
56
54
|
|
57
55
|
parcels.each do |parcel|
|
58
56
|
raise TypeError, "item in parcels array expected to be a ParcelEntity but got: #{parcel.class}" unless parcel.is_a?(::EnviaYa::Shared::Domain::Entities::ParcelEntity)
|
@@ -19,7 +19,8 @@ module EnviaYa
|
|
19
19
|
def execute(create_rate_dto)
|
20
20
|
raise TypeError, "create_rate_repository expected a CreateRateDto but got: #{create_rate_dto.class}" unless create_rate_dto.is_a?(::EnviaYa::Rates::Domain::Dtos::CreateRateDto)
|
21
21
|
|
22
|
-
@http_connector.execute(URI('https://enviaya.com.mx/api/v1/rates'), method: ::EnviaYa::Shared::Domain::ValueObjects::HttpMethodValueObject.new('POST'), body: create_rate_dto.to_hash)
|
22
|
+
response = @http_connector.execute(URI('https://enviaya.com.mx/api/v1/rates'), method: ::EnviaYa::Shared::Domain::ValueObjects::HttpMethodValueObject.new('POST'), body: create_rate_dto.to_hash)
|
23
|
+
JSON.parse(response.body, symbolize_names: true)
|
23
24
|
end
|
24
25
|
end
|
25
26
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: envia_ya
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Simply Development
|
@@ -22,14 +22,14 @@ files:
|
|
22
22
|
- lib/envia_ya.rb
|
23
23
|
- lib/modules/rates/application/commands/create_rate_command.rb
|
24
24
|
- lib/modules/rates/domain/dtos/create_rate_dto.rb
|
25
|
+
- lib/modules/rates/domain/entities/direction_entity.rb
|
26
|
+
- lib/modules/rates/domain/entities/shipment_entity.rb
|
25
27
|
- lib/modules/rates/domain/repositories/create_rate_repository.rb
|
26
28
|
- lib/modules/rates/infrastructure/repositories/create_rate_repository/create_rate_http_repository.rb
|
27
29
|
- lib/modules/shared/domain/connectors/http_connector.rb
|
28
30
|
- lib/modules/shared/domain/entities/accounts_entity.rb
|
29
|
-
- lib/modules/shared/domain/entities/direction_entity.rb
|
30
31
|
- lib/modules/shared/domain/entities/parcel_entity.rb
|
31
32
|
- lib/modules/shared/domain/entities/rate_entity.rb
|
32
|
-
- lib/modules/shared/domain/entities/shipment_entity.rb
|
33
33
|
- lib/modules/shared/domain/entities/surcharge_entity.rb
|
34
34
|
- lib/modules/shared/domain/value_objects/dimension_unit_value_object.rb
|
35
35
|
- lib/modules/shared/domain/value_objects/http_method_value_object.rb
|