-
Notifications
You must be signed in to change notification settings - Fork 137
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
1 parent
d71445d
commit 07950ea
Showing
10 changed files
with
63 additions
and
63 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
18 changes: 9 additions & 9 deletions
18
libs/apifaker/src/main/java/com/woocommerce/android/apifaker/db/EndpointTypeConverter.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,24 +1,24 @@ | ||
package com.woocommerce.android.apifaker.db | ||
|
||
import androidx.room.TypeConverter | ||
import com.woocommerce.android.apifaker.models.EndpointType | ||
import com.woocommerce.android.apifaker.models.ApiType | ||
|
||
internal class EndpointTypeConverter { | ||
@TypeConverter | ||
fun fromEndpointType(endpointType: EndpointType?): String? { | ||
if (endpointType == null) return null | ||
return endpointType::class.simpleName + | ||
if (endpointType is EndpointType.Custom) ":${endpointType.host}" else "" | ||
fun fromEndpointType(apiType: ApiType?): String? { | ||
if (apiType == null) return null | ||
return apiType::class.simpleName + | ||
if (apiType is ApiType.Custom) ":${apiType.host}" else "" | ||
} | ||
|
||
@TypeConverter | ||
fun toEndpointType(value: String?): EndpointType? { | ||
fun toEndpointType(value: String?): ApiType? { | ||
if (value == null) return null | ||
val parts = value.split(":") | ||
return when (parts[0]) { | ||
EndpointType.WPApi::class.simpleName -> EndpointType.WPApi | ||
EndpointType.WPCom::class.simpleName -> EndpointType.WPCom | ||
else -> EndpointType.Custom(parts[1]) | ||
ApiType.WPApi::class.simpleName -> ApiType.WPApi | ||
ApiType.WPCom::class.simpleName -> ApiType.WPCom | ||
else -> ApiType.Custom(parts[1]) | ||
} | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
libs/apifaker/src/main/java/com/woocommerce/android/apifaker/models/ApiType.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,12 @@ | ||
package com.woocommerce.android.apifaker.models | ||
|
||
internal sealed interface ApiType { | ||
companion object { | ||
fun defaultValues(): List<ApiType> = listOf(WPApi, WPCom, Custom("")) | ||
} | ||
|
||
data object WPApi : ApiType | ||
data object WPCom : ApiType | ||
|
||
data class Custom(val host: String) : ApiType | ||
} |
12 changes: 0 additions & 12 deletions
12
libs/apifaker/src/main/java/com/woocommerce/android/apifaker/models/EndpointType.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
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