theseus/app/services/customs_receipt.rb
2025-05-31 23:25:41 -04:00

48 lines
1.3 KiB
Ruby
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

module CustomsReceipt
class CustomsReceiptItem < Literal::Data
prop :name, String
prop :quantity, Integer
prop :value, _Any
end
class CustomsReceiptable < Literal::Data
prop :order_number, String
prop :tracking_number, _String?
prop :carrier, _String?
prop :not_gifted, _Boolean, default: false
prop :additional_info, _String?
prop :contents, _Array(CustomsReceiptItem)
prop :shipping_cost, _Any?
prop :recipient_address, String
def total_value
contents.sum { |item| item.quantity * item.value }
end
end
def mock_receiptable
CustomsReceiptable.new(
order_number: "pkg!sdfjkls",
tracking_number: "9400182239154327",
not_gifted: false,
additional_info: "This package is nothing to worry about.",
contents: [
CustomsReceiptItem.new(
name: "$30K in cash",
quantity: 3,
value: 30_000.99,
),
CustomsReceiptItem.new(
name: "*mysterious ticking noise...*",
quantity: 1,
value: 29.95,
),
],
shipping_cost: 5.99,
recipient_address: "ATTN: Director of Commercial Payment\nUS Postal Service\n475 LEnfant Plz SW Rm 3436\nWashington DC 20260-4110\nUSA",
carrier: "USPS",
)
end
module_function :mock_receiptable
end