This repository has been archived by the owner on Feb 4, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 37
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 #3106 from wordpress-mobile/woo/subscriptions-off-…
…product [Woo] Extract subscriptions outside of WCProductModel table
- Loading branch information
Showing
14 changed files
with
199 additions
and
102 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
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
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
41 changes: 41 additions & 0 deletions
41
...woocommerce/src/main/kotlin/org/wordpress/android/fluxc/model/metadata/MetadataChanges.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,41 @@ | ||
package org.wordpress.android.fluxc.model.metadata | ||
|
||
import com.google.gson.JsonArray | ||
import com.google.gson.JsonNull | ||
import com.google.gson.JsonObject | ||
|
||
data class MetadataChanges( | ||
val insertedMetadata: List<WCMetaData> = emptyList(), | ||
val updatedMetadata: List<WCMetaData> = emptyList(), | ||
val deletedMetadataIds: List<Long> = emptyList(), | ||
) { | ||
init { | ||
// The ID of inserted metadata is ignored, so to ensure that there is no data loss here, | ||
// we require that all inserted metadata have an ID of 0. | ||
require(insertedMetadata.all { it.id == 0L }) { | ||
"Inserted metadata must have an ID of 0" | ||
} | ||
} | ||
|
||
internal fun toJsonArray() = JsonArray().apply { | ||
insertedMetadata.forEach { | ||
add( | ||
JsonObject().apply { | ||
addProperty(WCMetaData.KEY, it.key) | ||
add(WCMetaData.VALUE, it.value.jsonValue) | ||
} | ||
) | ||
} | ||
updatedMetadata.forEach { | ||
add(it.toJson()) | ||
} | ||
deletedMetadataIds.forEach { | ||
add( | ||
JsonObject().apply { | ||
addProperty(WCMetaData.ID, it) | ||
add(WCMetaData.VALUE, JsonNull.INSTANCE) | ||
} | ||
) | ||
} | ||
} | ||
} |
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
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
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.