1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
//! `ProductOrderItem` — one line on a product order.
use crate::core::macros::tmf_struct;
use crate::core::{
Appointment, BillingAccount, ItemAction, Note, Payment, ProductOfferingQualification, Ref,
};
use crate::product::{Product, ProductOffering};
use super::common::{OrderPrice, OrderTerm};
use super::state::ProductOrderItemState;
tmf_struct! {
@name = "ProductOrderItem";
/// One line on a [`ProductOrder`](super::ProductOrder): an action to take on
/// one product.
///
/// Items nest — a bundle offering produces a parent item with children —
/// which is why `product_order_item` is a `Vec` of the same type.
pub struct ProductOrderItem {
/// Identifier of the line, unique within the order.
id: String,
/// What to do with the product.
action: ItemAction,
/// Fulfilment state of this line.
state: ProductOrderItemState,
/// How many.
quantity: i64,
/// The catalog offering being ordered.
product_offering: Ref<ProductOffering>,
/// The product being created or changed.
product: Product,
/// Prices for this line.
item_price: Vec<OrderPrice>,
/// Roll-up totals for this line and its children.
item_total_price: Vec<OrderPrice>,
/// Contractual terms for this line.
item_term: Vec<OrderTerm>,
/// Account this line is billed to.
billing_account: Ref<BillingAccount>,
/// Payments settling this line — TMF676.
payment: Vec<Ref<Payment>>,
/// Appointment booked to fulfil this line — TMF646.
appointment: Ref<Appointment>,
/// The qualification that established this line is deliverable — TMF679.
qualification: Vec<Ref<ProductOfferingQualification>>,
/// The qualification line this order line came from — TMF679.
product_offering_qualification_item: ProductOfferingQualificationItemRef,
/// The quote line this order line came from — TMF648.
quote_item: QuoteItemRef,
/// Nested lines, for a bundle.
product_order_item: Vec<ProductOrderItem>,
/// Relationships to other lines on the same order.
product_order_item_relationship: Vec<OrderItemRelationship>,
/// Notes attached to this line.
note: Vec<Note>,
}
}
tmf_struct! {
@name = "ProductOrderItem";
/// Body of one line in a `POST /productOrder` — the v5 `ProductOrderItem_FVO`.
///
/// `id` and `action` are required on create: a line the provider cannot
/// identify or act on is meaningless.
///
/// ```
/// use rutmf::core::{ItemAction, Ref};
/// use rutmf::order::ProductOrderItemCreate;
/// use rutmf::product::ProductOffering;
///
/// let line = ProductOrderItemCreate::builder()
/// .id("1")
/// .action(ItemAction::Add)
/// .product_offering(Ref::<ProductOffering>::new("7655"))
/// .quantity(2)
/// .build();
/// assert_eq!(line.id, "1");
/// ```
pub struct ProductOrderItemCreate {
@required {
/// Identifier of the line, unique within the order. **Required on create.**
id: String,
/// What to do with the product. **Required on create.**
action: ItemAction,
}
/// Requested initial state of this line.
state: ProductOrderItemState,
/// How many.
quantity: i64,
/// The catalog offering being ordered.
product_offering: Ref<ProductOffering>,
/// The product being created or changed.
product: Product,
/// Prices for this line.
item_price: Vec<OrderPrice>,
/// Roll-up totals for this line and its children.
item_total_price: Vec<OrderPrice>,
/// Contractual terms for this line.
item_term: Vec<OrderTerm>,
/// Account this line is billed to.
billing_account: Ref<BillingAccount>,
/// Payments settling this line.
payment: Vec<Ref<Payment>>,
/// Appointment booked to fulfil this line.
appointment: Ref<Appointment>,
/// The qualification that established this line is deliverable.
qualification: Vec<Ref<ProductOfferingQualification>>,
/// The qualification line this order line came from.
product_offering_qualification_item: ProductOfferingQualificationItemRef,
/// The quote line this order line came from.
quote_item: QuoteItemRef,
/// Nested lines, for a bundle.
product_order_item: Vec<ProductOrderItemCreate>,
/// Relationships to other lines on the same order.
product_order_item_relationship: Vec<OrderItemRelationship>,
/// Notes attached to this line.
note: Vec<Note>,
}
}
impl ProductOrderItemCreate {
/// A line adding the given offering.
pub fn add(id: impl Into<String>, offering: Ref<ProductOffering>) -> Self {
Self::builder()
.id(id)
.action(ItemAction::Add)
.product_offering(offering)
.build()
}
}
tmf_struct! {
@name = "QuoteItemRef";
/// A line of a quote an order line came from — TMF648.
///
/// One of the four v5 "item reference" shapes, which address a line *within*
/// a parent resource and so carry no `id`/`href` of their own. That is why
/// they are structs rather than [`Ref<T>`](crate::core::Ref), whose `id` is
/// mandatory.
pub struct QuoteItemRef {
/// Identifier of the quote.
quote_id: String,
/// URI of the quote.
quote_href: String,
/// Identifier of the line within the quote.
quote_item_id: String,
@renamed {
/// The concrete class of the quote.
"@referredType" referred_type: String,
}
}
}
tmf_struct! {
@name = "ProductOfferingQualificationItemRef";
/// A line of a product offering qualification — TMF679.
///
/// See [`QuoteItemRef`] for why this is a struct rather than a `Ref<T>`.
pub struct ProductOfferingQualificationItemRef {
/// Identifier of the qualification.
product_offering_qualification_id: String,
/// URI of the qualification.
product_offering_qualification_href: String,
/// Name of the qualification.
product_offering_qualification_name: String,
/// Identifier of the line within the qualification.
item_id: String,
@renamed {
/// The concrete class of the qualification.
"@referredType" referred_type: String,
}
}
}
tmf_struct! {
@name = "ProductOrderItemRef";
/// A line of a product order, addressed from outside it.
///
/// See [`QuoteItemRef`] for why this is a struct rather than a `Ref<T>`.
pub struct ProductOrderItemRef {
/// Identifier of the order.
product_order_id: String,
/// Identifier of the line within the order.
product_order_item_id: String,
@renamed {
/// URI of the order.
///
/// The v5 schema spells this member with a leading capital, unlike
/// every other member in the document. It is reproduced verbatim
/// because that is what a conformant server sends.
"ProductOrderHref" product_order_href: String,
/// The concrete class of the order.
"@referredType" referred_type: String,
}
}
}
tmf_struct! {
@name = "OrderItemRelationship";
/// A dependency between two lines on the same order.
pub struct OrderItemRelationship {
/// Identifier of the related line.
id: String,
/// Kind of relationship, e.g. `reliesOn`.
relationship_type: String,
}
}