@@ -23,14 +23,17 @@ public struct Order: Decodable {
2323 public let shippingTax : String
2424 public let total : String
2525 public let totalTax : String
26+ public let paymentMethodTitle : String
2627
2728 public let items : [ OrderItem ]
2829 public let billingAddress : Address
2930 public let shippingAddress : Address
31+ public let coupons : [ OrderCouponLine ]
3032
3133 /// Order struct initializer.
3234 ///
33- init ( orderID: Int , parentID: Int , customerID: Int , number: String , status: OrderStatus , currency: String , customerNote: String ? , dateCreated: Date , dateModified: Date , datePaid: Date ? , discountTotal: String , discountTax: String , shippingTotal: String , shippingTax: String , total: String , totalTax: String , items: [ OrderItem ] , billingAddress: Address , shippingAddress: Address ) {
35+ init ( orderID: Int , parentID: Int , customerID: Int , number: String , status: OrderStatus , currency: String , customerNote: String ? , dateCreated: Date , dateModified: Date , datePaid: Date ? , discountTotal: String , discountTax: String , shippingTotal: String , shippingTax: String , total: String , totalTax: String , paymentMethodTitle: String , items: [ OrderItem ] , billingAddress: Address , shippingAddress: Address , coupons: [ OrderCouponLine ] ) {
36+
3437 self . orderID = orderID
3538 self . parentID = parentID
3639 self . customerID = customerID
@@ -50,10 +53,12 @@ public struct Order: Decodable {
5053 self . shippingTax = shippingTax
5154 self . total = total
5255 self . totalTax = totalTax
56+ self . paymentMethodTitle = paymentMethodTitle
5357
5458 self . items = items
5559 self . billingAddress = billingAddress
5660 self . shippingAddress = shippingAddress
61+ self . coupons = coupons
5762 }
5863
5964
@@ -80,12 +85,14 @@ public struct Order: Decodable {
8085 let shippingTotal = try container. decode ( String . self, forKey: . shippingTotal)
8186 let total = try container. decode ( String . self, forKey: . total)
8287 let totalTax = try container. decode ( String . self, forKey: . totalTax)
88+ let paymentMethodTitle = try container. decode ( String . self, forKey: . paymentMethodTitle)
8389
8490 let items = try container. decode ( [ OrderItem ] . self, forKey: . items)
8591 let shippingAddress = try container. decode ( Address . self, forKey: . shippingAddress)
8692 let billingAddress = try container. decode ( Address . self, forKey: . billingAddress)
93+ let coupons = try container. decode ( [ OrderCouponLine ] . self, forKey: . couponLines)
8794
88- self . init ( orderID: orderID, parentID: parentID, customerID: customerID, number: number, status: status, currency: currency, customerNote: customerNote, dateCreated: dateCreated, dateModified: dateModified, datePaid: datePaid, discountTotal: discountTotal, discountTax: discountTax, shippingTotal: shippingTotal, shippingTax: shippingTax, total: total, totalTax: totalTax, items: items, billingAddress: billingAddress, shippingAddress: shippingAddress) // initialize the struct
95+ self . init ( orderID: orderID, parentID: parentID, customerID: customerID, number: number, status: status, currency: currency, customerNote: customerNote, dateCreated: dateCreated, dateModified: dateModified, datePaid: datePaid, discountTotal: discountTotal, discountTax: discountTax, shippingTotal: shippingTotal, shippingTax: shippingTax, total: total, totalTax: totalTax, paymentMethodTitle : paymentMethodTitle , items: items, billingAddress: billingAddress, shippingAddress: shippingAddress, coupons : coupons ) // initialize the struct
8996 }
9097}
9198
@@ -114,10 +121,12 @@ private extension Order {
114121 case shippingTax = " shipping_tax "
115122 case total = " total "
116123 case totalTax = " total_tax "
124+ case paymentMethodTitle = " payment_method_title "
117125
118126 case items = " line_items "
119127 case shippingAddress = " shipping "
120128 case billingAddress = " billing "
129+ case couponLines = " coupon_lines "
121130 }
122131}
123132
@@ -140,8 +149,10 @@ extension Order: Comparable {
140149 lhs. shippingTax == rhs. shippingTax &&
141150 lhs. total == rhs. total &&
142151 lhs. totalTax == rhs. totalTax &&
152+ lhs. paymentMethodTitle == rhs. paymentMethodTitle &&
143153 lhs. billingAddress == rhs. billingAddress &&
144154 lhs. shippingAddress == rhs. shippingAddress &&
155+ lhs. coupons == rhs. coupons &&
145156 lhs. items. count == rhs. items. count &&
146157 lhs. items. sorted ( ) == rhs. items. sorted ( )
147158 }
0 commit comments