-
Notifications
You must be signed in to change notification settings - Fork 135
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12766 from woocommerce/issue/12752-subscriptions-…
…meta-1 [Products] Extract subscriptions outside of the Product DB table - Part 1
- Loading branch information
Showing
16 changed files
with
820 additions
and
693 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
WooCommerce/src/main/kotlin/com/woocommerce/android/model/ProductAggregate.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package com.woocommerce.android.model | ||
|
||
import android.os.Parcelable | ||
import kotlinx.parcelize.Parcelize | ||
|
||
/** | ||
* Container class for product and any additional details that are stored as product metadata. | ||
* | ||
* For now, the additional details include subscription details only. | ||
* | ||
* @param product The product. | ||
* @param subscription The subscription details. | ||
*/ | ||
@Parcelize | ||
data class ProductAggregate( | ||
val product: Product, | ||
val subscription: SubscriptionDetails? = null | ||
) : Parcelable { | ||
val remoteId: Long | ||
get() = product.remoteId | ||
|
||
val hasShipping: Boolean | ||
get() = product.hasShipping || subscription?.oneTimeShipping == true | ||
|
||
fun isSame(other: ProductAggregate): Boolean { | ||
return product.isSameProduct(other.product) && subscription == other.subscription | ||
} | ||
|
||
fun merge(other: ProductAggregate): ProductAggregate { | ||
return copy( | ||
product = product.mergeProduct(other.product), | ||
subscription = other.subscription | ||
) | ||
} | ||
} |
124 changes: 60 additions & 64 deletions
124
WooCommerce/src/main/kotlin/com/woocommerce/android/model/SubscriptionDetailsMapper.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.