Skip to content
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

EIT-2067: update dependencies #176

Merged
merged 9 commits into from
Oct 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ indent_size = 4
insert_final_newline = true
trim_trailing_whitespace = true

[*.{kt,kts}]
ij_kotlin_allow_trailing_comma=true
ij_kotlin_allow_trailing_comma_on_call_site=true

[*.md]
trim_trailing_whitespace = false

Expand Down
14 changes: 8 additions & 6 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Clone Repository
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Set up JDK 11
uses: actions/setup-java@v1
uses: actions/setup-java@v2
with:
java-version: '11'
java-version: 11
distribution: 'zulu'

- name: Lint
run: ./gradlew afterpay:lintDebug afterpay:ktlint
Expand All @@ -30,12 +31,13 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Clone Repository
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Set up JDK 11
uses: actions/setup-java@v1
uses: actions/setup-java@v2
with:
java-version: '11'
java-version: 11
distribution: 'zulu'

- name: Build and Lint
run: ./gradlew example:buildDebug example:lintDebug example:ktlint
7 changes: 4 additions & 3 deletions .github/workflows/release-snapshot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Clone Repository
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Set up JDK 11
uses: actions/setup-java@v1
uses: actions/setup-java@v2
with:
java-version: '11'
java-version: 11
distribution: 'zulu'

- name: Clean repository before building SDK
run: ./gradlew clean
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Clone Repository
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Set up JDK 11
uses: actions/setup-java@v1
uses: actions/setup-java@v2
with:
java-version: '11'
java-version: 11
distribution: 'zulu'

- name: Remove SNAPSHOT from version
run: sed -i 's/-SNAPSHOT//g' gradle.properties
Expand Down
37 changes: 37 additions & 0 deletions .idea/androidTestResultsUserPreferences.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 0 additions & 9 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions .idea/deploymentTargetDropDown.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion afterpay/consumer-rules.pro
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
-keepattributes *Annotation*, InnerClasses
-dontnote kotlinx.serialization.AnnotationsKt # core serialization annotations

# kotlinx-serialization-json specific. Add this if you have java.lang.NoClassDefFoundError kotlinx.serialization.json.JsonObjectSerializer
-keepclassmembers class kotlinx.serialization.json.** {
Expand Down
8 changes: 4 additions & 4 deletions afterpay/src/main/kotlin/com/afterpay/android/Afterpay.kt
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ object Afterpay {
@JvmStatic
fun createCheckoutV2Intent(
context: Context,
options: AfterpayCheckoutV2Options = AfterpayCheckoutV2Options()
options: AfterpayCheckoutV2Options = AfterpayCheckoutV2Options(),
): Intent = Intent(context, AfterpayCheckoutV2Activity::class.java)
.putCheckoutV2OptionsExtra(options)

Expand Down Expand Up @@ -107,14 +107,14 @@ object Afterpay {
maximumAmount: String,
currencyCode: String,
locale: Locale,
environment: AfterpayEnvironment
environment: AfterpayEnvironment,
) {
configuration = Configuration(
minimumAmount = minimumAmount?.toBigDecimal(),
maximumAmount = maximumAmount.toBigDecimal(),
currency = Currency.getInstance(currencyCode),
locale = locale.clone() as Locale,
environment = environment
environment = environment,
).also { configuration ->
if (configuration.maximumAmount < BigDecimal.ZERO) {
throw IllegalArgumentException("Maximum order amount is invalid")
Expand All @@ -128,7 +128,7 @@ object Afterpay {
val validCountries = Locales.validSet.map { it.country }
throw IllegalArgumentException(
"Locale contains an unsupported country: ${configuration.locale.country}. " +
"Supported countries include: ${validCountries.joinToString(",")}"
"Supported countries include: ${validCountries.joinToString(",")}",
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ interface AfterpayCheckoutV2Handler {

fun shippingAddressDidChange(
address: ShippingAddress,
onProvideShippingOptions: (ShippingOptionsResult) -> Unit
onProvideShippingOptions: (ShippingOptionsResult) -> Unit,
)

fun shippingOptionDidChange(
shippingOption: ShippingOption,
onProvideShippingOption: (ShippingOptionUpdateResult?) -> Unit
onProvideShippingOption: (ShippingOptionUpdateResult?) -> Unit,
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ data class AfterpayCheckoutV2Options(
val pickup: Boolean? = null,
val buyNow: Boolean? = null,
val shippingOptionRequired: Boolean? = null,
val enableSingleShippingOptionUpdate: Boolean? = null
val enableSingleShippingOptionUpdate: Boolean? = null,
) : Parcelable {
constructor(parcel: Parcel) : this(
parcel.readValue(Boolean::class.java.classLoader) as? Boolean,
parcel.readValue(Boolean::class.java.classLoader) as? Boolean,
parcel.readValue(Boolean::class.java.classLoader) as? Boolean,
parcel.readValue(Boolean::class.java.classLoader) as? Boolean
parcel.readValue(Boolean::class.java.classLoader) as? Boolean,
)

override fun writeToParcel(parcel: Parcel, flags: Int) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ import java.util.Locale
enum class AfterpayEnvironment {
SANDBOX, PRODUCTION;

override fun toString(): String = name.toLowerCase(Locale.ROOT)
override fun toString(): String = name.lowercase(Locale.ROOT)
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import kotlinx.serialization.Serializable
@Serializable
internal data class AfterpayCheckoutCompletion(
val status: Status,
val orderToken: String
val orderToken: String,
) {

@Suppress("UNUSED_PARAMETER")
@Serializable
internal enum class Status(statusString: String) {
SUCCESS("SUCCESS"),
CANCELLED("CANCELLED")
CANCELLED("CANCELLED"),
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,20 @@ internal sealed class AfterpayCheckoutMessage {

fun fromShippingOptionsResult(
result: ShippingOptionsResult,
meta: AfterpayCheckoutMessageMeta
meta: AfterpayCheckoutMessageMeta,
): AfterpayCheckoutMessage = when (result) {
is ShippingOptionsErrorResult -> CheckoutErrorMessage(meta, result.error.name)
is ShippingOptionsSuccessResult -> ShippingOptionsMessage(meta, result.shippingOptions)
}

fun fromShippingOptionUpdateResult(
result: ShippingOptionUpdateResult?,
meta: AfterpayCheckoutMessageMeta
meta: AfterpayCheckoutMessageMeta,
): AfterpayCheckoutMessage = when (result) {
is ShippingOptionUpdateErrorResult -> CheckoutErrorMessage(meta, result.error.name)
is ShippingOptionUpdateSuccessResult -> ShippingOptionUpdateMessage(
meta,
result.shippingOptionUpdate
result.shippingOptionUpdate,
)
null -> EmptyPayloadMessage(meta)
}
Expand All @@ -48,53 +48,53 @@ internal sealed class AfterpayCheckoutMessage {
@SerialName("onMessage")
internal data class CheckoutLogMessage(
override val meta: AfterpayCheckoutMessageMeta,
val payload: CheckoutLog
val payload: CheckoutLog,
) : AfterpayCheckoutMessage() {

@Serializable
internal data class CheckoutLog(
val severity: String,
val message: String
val message: String,
)
}

@Serializable
@SerialName("onError")
internal data class CheckoutErrorMessage(
override val meta: AfterpayCheckoutMessageMeta,
val error: String
val error: String,
) : AfterpayCheckoutMessage()

@Serializable
@SerialName("onShippingAddressChange")
internal data class ShippingAddressMessage(
override val meta: AfterpayCheckoutMessageMeta,
val payload: ShippingAddress
val payload: ShippingAddress,
) : AfterpayCheckoutMessage()

@Serializable
@SerialName("onShippingOptionChange")
internal data class ShippingOptionMessage(
override val meta: AfterpayCheckoutMessageMeta,
val payload: ShippingOption
val payload: ShippingOption,
) : AfterpayCheckoutMessage()

@Serializable
@SerialName("onShippingOptionUpdateChange")
internal data class ShippingOptionUpdateMessage(
override val meta: AfterpayCheckoutMessageMeta,
val payload: ShippingOptionUpdate?
val payload: ShippingOptionUpdate?,
) : AfterpayCheckoutMessage()

@Serializable
@SerialName("onShippingOptionsChange")
internal data class ShippingOptionsMessage(
override val meta: AfterpayCheckoutMessageMeta,
val payload: List<ShippingOption>
val payload: List<ShippingOption>,
) : AfterpayCheckoutMessage()

@Serializable
@SerialName("onEmptyPayload")
internal data class EmptyPayloadMessage(
override val meta: AfterpayCheckoutMessageMeta
override val meta: AfterpayCheckoutMessageMeta,
) : AfterpayCheckoutMessage()
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ internal data class AfterpayCheckoutV2(
constructor(
token: String,
configuration: Configuration,
options: AfterpayCheckoutV2Options
options: AfterpayCheckoutV2Options,
) : this(
token = token,
locale = configuration.locale.toString(),
Expand All @@ -30,6 +30,6 @@ internal data class AfterpayCheckoutV2(
buyNow = options.buyNow,
shippingOptionRequired = options.shippingOptionRequired,
checkoutRedesignForced = options.enableSingleShippingOptionUpdate,
consumerLocale = Afterpay.language.toString()
consumerLocale = Afterpay.language.toString(),
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ internal enum class AfterpayDrawable(
buttonCheckoutForeground = R.drawable.clearpay_button_checkout_fg_es,
buttonPayNowForeground = R.drawable.clearpay_button_pay_now_fg_es,
buttonPlaceOrderForeground = R.drawable.clearpay_button_place_order_fg_es,
);
),
;

companion object {
fun forLocale(): AfterpayDrawable {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ import java.util.Locale

internal sealed class AfterpayInstalment {
data class Available(
val instalmentAmount: String
val instalmentAmount: String,
) : AfterpayInstalment()

data class NotAvailable(
val minimumAmount: String?,
val maximumAmount: String
val maximumAmount: String,
) : AfterpayInstalment()

object NoConfiguration : AfterpayInstalment()
Expand Down Expand Up @@ -83,7 +83,7 @@ internal sealed class AfterpayInstalment {

return NotAvailable(
minimumAmount = configuration.minimumAmount?.let(currencyFormatterNoDecimals::format),
maximumAmount = currencyFormatterNoDecimals.format(configuration.maximumAmount)
maximumAmount = currencyFormatterNoDecimals.format(configuration.maximumAmount),
)
}

Expand Down
Loading