-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
61 additions
and
125 deletions.
There are no files selected for viewing
32 changes: 0 additions & 32 deletions
32
sdk/src/main/java/com/magicbell/sdk/common/network/graphql/CursorPredicate.kt
This file was deleted.
Oops, something went wrong.
5 changes: 0 additions & 5 deletions
5
sdk/src/main/java/com/magicbell/sdk/common/network/graphql/GraphQLRepresentable.kt
This file was deleted.
Oops, something went wrong.
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
15 changes: 2 additions & 13 deletions
15
sdk/src/main/java/com/magicbell/sdk/feature/store/StoreContext.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 |
---|---|---|
@@ -1,17 +1,6 @@ | ||
package com.magicbell.sdk.feature.store | ||
|
||
import com.magicbell.sdk.common.network.graphql.CursorPredicate | ||
import com.magicbell.sdk.common.network.graphql.GraphQLRepresentable | ||
|
||
internal class StoreContext( | ||
val storePredicate: StorePredicate, | ||
val cursorPredicate: CursorPredicate, | ||
) : GraphQLRepresentable { | ||
override val graphQLValue: String | ||
get() { | ||
val storePredicateString = storePredicate.graphQLValue | ||
val cursorPredicateString = cursorPredicate.graphQLValue | ||
|
||
return " data: notifications ($storePredicateString, $cursorPredicateString) { ...notification }" | ||
} | ||
} | ||
val storePagePredicate: StorePagePredicate, | ||
) |
6 changes: 6 additions & 0 deletions
6
sdk/src/main/java/com/magicbell/sdk/feature/store/StorePagePredicate.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,6 @@ | ||
package com.magicbell.sdk.feature.store | ||
|
||
internal data class StorePagePredicate( | ||
val page: Int, | ||
val size: Int, | ||
) |
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
14 changes: 4 additions & 10 deletions
14
sdk/src/main/java/com/magicbell/sdk/feature/store/data/StoreQuery.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 |
---|---|---|
@@ -1,25 +1,19 @@ | ||
package com.magicbell.sdk.feature.store.data | ||
|
||
import com.mobilejazz.harmony.data.query.Query | ||
import com.magicbell.sdk.common.network.graphql.CursorPredicate | ||
import com.magicbell.sdk.common.network.graphql.GraphQLRepresentable | ||
import com.magicbell.sdk.common.query.UserQuery | ||
import com.magicbell.sdk.feature.store.StoreContext | ||
import com.magicbell.sdk.feature.store.StorePagePredicate | ||
import com.magicbell.sdk.feature.store.StorePredicate | ||
|
||
internal class StoreQuery( | ||
val context: StoreContext, | ||
val userQuery: UserQuery, | ||
) : Query(), GraphQLRepresentable { | ||
) : Query() { | ||
|
||
constructor( | ||
storePredicate: StorePredicate, | ||
cursorPredicate: CursorPredicate, | ||
storePagePredicate: StorePagePredicate, | ||
userQuery: UserQuery, | ||
) : this(StoreContext(storePredicate, cursorPredicate), userQuery) | ||
|
||
override val graphQLValue: String | ||
get() { | ||
return context.graphQLValue | ||
} | ||
) : this(StoreContext(storePredicate, storePagePredicate), userQuery) | ||
} |
31 changes: 31 additions & 0 deletions
31
sdk/src/main/java/com/magicbell/sdk/feature/store/data/StoreQueryParameter.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,31 @@ | ||
package com.magicbell.sdk.feature.store.data | ||
|
||
import com.magicbell.sdk.feature.store.StoreContext | ||
import com.magicbell.sdk.feature.store.StorePagePredicate | ||
import com.magicbell.sdk.feature.store.StorePredicate | ||
|
||
internal fun StoreContext.asQueryParameters(): Map<String, String> { | ||
return storePredicate.asQueryParameters() + storePagePredicate.asQueryParameters() | ||
} | ||
|
||
private fun StorePredicate.asQueryParameters(): Map<String, String> { | ||
val result: MutableMap<String, String> = mutableMapOf() | ||
read?.let { | ||
result["read"] = "$read" | ||
} | ||
seen?.let { | ||
result["seen"] = "$seen" | ||
} | ||
result["archived"] = "$archived" | ||
|
||
|
||
return result | ||
} | ||
|
||
private fun StorePagePredicate.asQueryParameters(): Map<String, String> { | ||
return mapOf( | ||
"page" to "$page", | ||
"per_page" to "$size", | ||
) | ||
} | ||
|
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