Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Turn Delivery#address into separate object, Zaikio::Procurement::Address #18

Merged
merged 1 commit into from Nov 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 5 additions & 2 deletions CHANGELOG.md
Expand Up @@ -7,9 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

- Turn `Delivery#address` into a separate `Zaikio::Procurement::Address` object. This
change is breaking if you previously depended on this property being a Hash.

## [0.3.1] - 2021-10-28
- **Breaking change for Supplier API**: When operating on `Article` or `Variant` one must provide scope
of `substrate` or `plate`. Calling `all` or `find` without scope will raise an `ArgumentError`
- **Breaking change for Supplier API**: When operating on `Article` or `Variant` one must provide scope
of `substrate` or `plate`. Calling `all` or `find` without scope will raise an `ArgumentError`

## [0.2.2] - 2021-10-25

Expand Down
1 change: 1 addition & 0 deletions lib/zaikio/procurement.rb
Expand Up @@ -6,6 +6,7 @@

# Models
require "zaikio/procurement/base"
require "zaikio/procurement/address"
require "zaikio/procurement/article"
require "zaikio/procurement/variant"
require "zaikio/procurement/substrate_search"
Expand Down
22 changes: 22 additions & 0 deletions lib/zaikio/procurement/address.rb
@@ -0,0 +1,22 @@
module Zaikio
module Procurement
class Address < Base
attributes :addition,
:addressable,
:addressee,
:country_code,
:county,
:kind,
:location,
:number,
:state,
:street,
:text,
:town,
:types,
:zip_code,
:created_at,
:updated_at
end
end
end
7 changes: 4 additions & 3 deletions lib/zaikio/procurement/delivery.rb
Expand Up @@ -6,11 +6,12 @@ class Delivery < Base

# Attributes
attributes :confirmed_delivery_date, :desired_delivery_date, :references,
:address, :order_id, :created_at, :updated_at
:order_id, :created_at, :updated_at

# Associations
belongs_to :order, class_name: "Zaikio::Procurement::Order",
uri: nil
belongs_to :address, class_name: "Zaikio::Procurement::Address", uri: nil
belongs_to :order, class_name: "Zaikio::Procurement::Order", uri: nil

has_many :delivery_line_items, class_name: "Zaikio::Procurement::DeliveryLineItem",
uri: "deliveries/:delivery_id/delivery_line_items(/:id)"
end
Expand Down
3 changes: 2 additions & 1 deletion test/zaikio/procurement_consumer_test.rb
Expand Up @@ -376,11 +376,12 @@ def token
end
end

test "fetching a specific delivery" do
test "fetching a specific delivery and address" do
VCR.use_cassette("delivery") do
Zaikio::Procurement.with_token(token) do
delivery = Zaikio::Procurement::Delivery.find("46a67d80-ff21-403a-9cb3-5b3a9464ae0f")
assert_equal "46a67d80-ff21-403a-9cb3-5b3a9464ae0f", delivery.id
assert_equal "John Doe", delivery.address.addressee
end
end
end
Expand Down