Skip to content
This repository was archived by the owner on Aug 14, 2024. It is now read-only.

Commit 8af35b9

Browse files
authored
Add attr_accessor for service and additional_services to class Shipcloud::Shipment (#74)
* Add attr_accessor for `service` to class `Shipcloud::Shipment` * Add attr_accessor for `additional_services` to class `Shipcloud::Shipment`
1 parent 6845d15 commit 8af35b9

3 files changed

Lines changed: 38 additions & 5 deletions

File tree

CHANGELOG.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
## [0.11.0] - 2020-07-28
1+
## [Unreleased]
22
### Added
3-
- Support shipments with pickup requests as required for [TNT](https://developers.shipcloud.io/carriers/tnt.html).
4-
- Add attr_accessor for `email` to class `Shipcloud::Address` to be able to access the email attribute at the address object.
3+
- Add attr_accessor for `service` to class `Shipcloud::Shipment` to be able to access the service attribute at the shipment object.
4+
- Add attr_accessor for `additional_services` to class `Shipcloud::Shipment` to be able to access the additional_services attribute at the shipment object.
55

66
### Changed
77

@@ -13,8 +13,10 @@
1313

1414
### Security
1515

16-
## [Unreleased]
16+
## [0.11.0] - 2020-07-28
1717
### Added
18+
- Support shipments with pickup requests as required for [TNT](https://developers.shipcloud.io/carriers/tnt.html).
19+
- Add attr_accessor for `email` to class `Shipcloud::Address` to be able to access the email attribute at the address object.
1820

1921
### Changed
2022

lib/shipcloud/shipment.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ class Shipment < Base
44
include Shipcloud::Operations::Update
55
include Shipcloud::Operations::All
66

7-
attr_accessor :from, :to, :carrier, :package, :reference_number, :metadata
7+
attr_accessor :from, :to, :carrier, :service, :package, :reference_number, :metadata,
8+
:additional_services
89
attr_reader :id, :created_at, :carrier_tracking_no, :tracking_url, :label_url,
910
:packages, :price, :customs_declaration, :pickup
1011

spec/shipcloud/shipment_spec.rb

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
zip_code: '10000',
1414
},
1515
carrier: 'dhl',
16+
service: 'standard',
1617
package: {
1718
weight: 2.5,
1819
length: 40,
@@ -48,6 +49,20 @@
4849
id: "123456",
4950
contents_type: "commercial_goods",
5051
},
52+
additional_services: [
53+
{
54+
name: "cash_on_delivery",
55+
properties: {
56+
amount: 123.45,
57+
currency: "EUR",
58+
bank_account_holder: "Max Mustermann",
59+
bank_name: "Musterbank",
60+
bank_account_number: "DE12500105170648489890",
61+
bank_code: "BENEDEPPYYY",
62+
reference1: "reason for transfer",
63+
}
64+
}
65+
]
5166
}
5267
end
5368

@@ -66,6 +81,7 @@
6681
expect(shipment.to[:zip_code]).to eq '10000'
6782

6883
expect(shipment.carrier).to eq 'dhl'
84+
expect(shipment.service).to eq 'standard'
6985

7086
expect(shipment.package[:weight]).to eq 2.5
7187
expect(shipment.package[:length]).to eq 40
@@ -85,6 +101,20 @@
85101

86102
expect(shipment.customs_declaration[:id]).to eq "123456"
87103
expect(shipment.customs_declaration[:contents_type]).to eq "commercial_goods"
104+
expect(shipment.additional_services.first[:name]).to eq "cash_on_delivery"
105+
expect(shipment.additional_services.first[:properties][:amount]).to eq 123.45
106+
expect(shipment.additional_services.first[:properties][:currency]).to eq "EUR"
107+
expect(
108+
shipment.additional_services.first[:properties][:bank_account_holder],
109+
).to eq "Max Mustermann"
110+
expect(shipment.additional_services.first[:properties][:bank_name]).to eq "Musterbank"
111+
expect(
112+
shipment.additional_services.first[:properties][:bank_account_number],
113+
).to eq "DE12500105170648489890"
114+
expect(shipment.additional_services.first[:properties][:bank_code]).to eq "BENEDEPPYYY"
115+
expect(
116+
shipment.additional_services.first[:properties][:reference1],
117+
).to eq "reason for transfer"
88118
end
89119

90120
it "initializes the metadata correctly" do

0 commit comments

Comments
 (0)