-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[NT-1450] Allow Dissimilar Shipping Cost for Add-Ons #1257
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,7 @@ public struct AddOnData { | |
} | ||
|
||
public struct Reward { | ||
public var addOnData: AddOnData? | ||
public var addOnData: AddOnData? // FIXME: to be removed in future | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will be removed when we refactor this code. |
||
public let backersCount: Int? | ||
public let convertedMinimum: Double | ||
public let description: String | ||
|
@@ -22,7 +22,8 @@ public struct Reward { | |
public let minimum: Double | ||
public let remaining: Int? | ||
public let rewardsItems: [RewardsItem] | ||
public let shipping: Shipping | ||
public let shipping: Shipping // only v1 | ||
public let shippingRules: [ShippingRule]? // only GraphQL | ||
public let startsAt: TimeInterval? | ||
public let title: String? | ||
|
||
|
@@ -31,9 +32,20 @@ public struct Reward { | |
return self.id == Reward.noReward.id | ||
} | ||
|
||
/** | ||
Returns the closest matching `ShippingRule` for this `Reward` to `otherShippingRule`. | ||
If no match is found `otherShippingRule` is returned, this is to be backward-compatible | ||
with v1 Rewards that do not include the `shippingRules` array. | ||
*/ | ||
public func shippingRule(matching otherShippingRule: ShippingRule?) -> ShippingRule? { | ||
return self.shippingRules? | ||
.first { shippingRule in shippingRule.location.id == otherShippingRule?.location.id } | ||
?? otherShippingRule | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does it make sense to coalesce this to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would leave it as nil in the edge case that a shipping rule is not provided. I'm also wondering how we handle creators that specify free shipping? Will that still be a shipping rule? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, let me update to not coalesce this to the matching rule. Yes, I confirmed it will be returned as a shipping rule with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Update comment to explain that this is to work with legacy v1 |
||
} | ||
|
||
public struct Shipping: Swift.Decodable { | ||
public let enabled: Bool | ||
public let location: Location? | ||
public let location: Location? /// via v1 if `ShippingType` is `singleLocation` | ||
public let preference: Preference? | ||
public let summary: String? | ||
public let type: ShippingType? | ||
|
@@ -94,6 +106,7 @@ extension Reward: Argo.Decodable { | |
return tmp2 | ||
<*> ((json <|| "rewards_items") <|> .success([])) | ||
<*> tryDecodable(json) | ||
<*> json <||? "shipping_rules" | ||
<*> json <|? "starts_at" | ||
<*> json <|? "title" | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At the moment we don't need this data in the
ManagePledgeViewModel
.