Skip to content

Commit

Permalink
ECWID-141762 merge remote-tracking branch 'origin/master' into ECWID-…
Browse files Browse the repository at this point in the history
…141762
  • Loading branch information
n-viktorovich committed Jul 2, 2024
2 parents 037ae9f + b3e2b21 commit 0f23e56
Show file tree
Hide file tree
Showing 13 changed files with 42 additions and 4 deletions.
26 changes: 23 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,26 @@ apiHost=app.local.ecwid.com
apiPort=8443
```

#### Adding the Library to a Maven Project

To add the current library to a Maven project, you need to add the following block of code to your project's `pom.xml` file inside the `<dependencies>` tag:

```xml
<dependency>
<groupId>com.ecwid.apiclient</groupId>
<artifactId>api-client</artifactId>
<version>0.326.0</version>
</dependency>
```

#### Adding the Library to a Gradle Project

To add the current library to a Gradle project using Kotlin DSL, you need to add the following line to your project's `build.gradle.kts` file inside the `dependencies` block:

```kotlin
implementation("com.ecwid.apiclient:api-client:0.326.0")
```

## Examples

#### Simple example:
Expand All @@ -25,7 +45,7 @@ val apiClient = ApiClient.create(
storeId = 1003,
apiToken = "secret_mysecuretoken"),
httpTransport = ApacheCommonsHttpClientTransport(),
jsonTransformerProvider = GsonTransformerProvider()
jsonTransformerProvider = GsonTransformerProvider())

val customer = apiClient.getCustomerDetails(CustomerDetailsRequest(customerId = 1))
println("api/v3 customer: $customer")
Expand All @@ -39,7 +59,7 @@ val apiClient = ApiClient.create(
storeId = 1003,
apiToken = "secret_mysecuretoken"),
httpTransport = ApacheCommonsHttpClientTransport(),
jsonTransformerProvider = GsonTransformerProvider()
jsonTransformerProvider = GsonTransformerProvider())

val requestsForBatch = listOf(CustomerDetailsRequest(1), CustomerDetailsRequest(2))
val batch = apiClient.createBatch(CreateBatchRequest(requestsForBatch, stopOnFirstFailure = true))
Expand All @@ -57,6 +77,6 @@ while (true) {
.map { it.toTypedResponse(FetchedCustomer::class.java) }
.mapNotNull { if (it !is TypedBatchResponse.Ok<FetchedCustomer>) it.toString() else null }
println("api/v3 customers: ${customers.joinToString { it.id.toString() }}, errors: ${errors.joinToString()}")
break;
break
}
```
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ fun FetchedOrder.toUpdated(): UpdatedOrder {
giftCardDoubleSpending = giftCardDoubleSpending,
giftCardCode = giftCardCode,
giftCardId = giftCardId,
giftCardUuid = giftCardUuid,

tax = tax,
customerTaxExempt = customerTaxExempt,
Expand Down Expand Up @@ -336,5 +337,6 @@ fun FetchedOrder.LoyaltyRedemption.toUpdated(): UpdatedOrder.LoyaltyRedemption {
return UpdatedOrder.LoyaltyRedemption(
id = this.id,
amount = this.amount,
cancelled = this.cancelled,
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ data class OrderForCalculate(
val paymentOptionsDetails: PaymentOption? = null,
val giftCardCode: String? = null,
val giftCardId: Int? = null,
val giftCardUuid: String? = null,
val giftCardTransactionOrderId: Int? = null,
val giftCardRedemption: Double? = null,
val totalBeforeGiftCardRedemption: Double? = null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ data class CalculateOrderDetailsResult(
val giftCardDoubleSpending: Boolean? = null,
val giftCardCode: String? = null,
val giftCardId: Int? = null,
val giftCardUuid: String? = null,

val tax: Double? = null,
val taxesOnShipping: List<TaxOnShipping>? = null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ data class FetchedCart(

val giftCardCode: String? = null,
val giftCardId: Int? = null,
val giftCardUuid: String? = null,
val giftCardRedemption: Double? = null,
val totalBeforeGiftCardRedemption: Double? = null,
val giftCardDoubleSpending: Boolean? = null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ data class UpdatedOrder(
val giftCardDoubleSpending: Boolean? = null,
val giftCardCode: String? = null,
val giftCardId: Int? = null,
val giftCardUuid: String? = null,

val tax: Double? = null,
val customerTaxExempt: Boolean? = null,
Expand Down Expand Up @@ -357,6 +358,7 @@ data class UpdatedOrder(
val orderDetailsDisplaySection: String? = null,
val orderBy: String? = null
)

data class Loyalty(
val earned: Double? = null,
val redemption: LoyaltyRedemption? = null,
Expand All @@ -366,6 +368,7 @@ data class UpdatedOrder(
data class LoyaltyRedemption(
val id: String? = null,
val amount: Double? = null,
val cancelled: Boolean? = null,
)

companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ data class FetchedOrder(
val giftCardDoubleSpending: Boolean? = null,
val giftCardCode: String? = null,
val giftCardId: Int? = null,
val giftCardUuid: String? = null,

val total: Double? = null,
val totalWithoutTax: Double? = null,
Expand Down Expand Up @@ -521,5 +522,6 @@ data class FetchedOrder(
data class LoyaltyRedemption(
val id: String? = null,
val amount: Double? = null,
val cancelled: Boolean? = null,
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ enum class ReportType {
visitorsByDevice,
visitorsByCountry,
visitorsByLanguage,
topOfLandingPagesByVisitors,

/** orders */
allOrders,
Expand All @@ -37,6 +38,6 @@ enum class ReportType {
addToCartConversion,
checkoutSalesFunnel,
abandonedCarts,
topOfProductsByAddingToFavorites,

topOfLandingPagesByVisitors,
}
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ val nonUpdatablePropertyRules: List<NonUpdatablePropertyRule<*, *>> = listOf(
ReadOnly(FetchedCart::giftCardCode),
ReadOnly(FetchedCart::giftCardDoubleSpending),
ReadOnly(FetchedCart::giftCardId),
ReadOnly(FetchedCart::giftCardUuid),
ReadOnly(FetchedCart::giftCardRedemption),
ReadOnly(FetchedCart::totalBeforeGiftCardRedemption),
Ignored(FetchedCart::tax),
Expand Down Expand Up @@ -172,6 +173,7 @@ val nonUpdatablePropertyRules: List<NonUpdatablePropertyRule<*, *>> = listOf(
ReadOnly(FetchedOrder::giftCardCode),
ReadOnly(FetchedOrder::giftCardDoubleSpending),
ReadOnly(FetchedOrder::giftCardId),
ReadOnly(FetchedOrder::giftCardUuid),
ReadOnly(FetchedOrder::giftCardRedemption),
ReadOnly(FetchedOrder::totalBeforeGiftCardRedemption),
ReadOnly(FetchedOrder::totalWithoutTax),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ val calculateOrderDetailsResultNullablePropertyRules: List<NullablePropertyRule<
AllowNullable(CalculateOrderDetailsResult::giftCardDoubleSpending),
AllowNullable(CalculateOrderDetailsResult::giftCardCode),
AllowNullable(CalculateOrderDetailsResult::giftCardId),
AllowNullable(CalculateOrderDetailsResult::giftCardUuid),
AllowNullable(CalculateOrderDetailsResult::totalWithoutTax),
IgnoreNullable(CalculateOrderDetailsResult::usdTotal),
IgnoreNullable(CalculateOrderDetailsResult::volumeDiscount)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ val fetchedCartNullablePropertyRules: List<NullablePropertyRule<*, *>> = listOf(
AllowNullable(FetchedCart::giftCardCode),
AllowNullable(FetchedCart::giftCardDoubleSpending),
AllowNullable(FetchedCart::giftCardId),
AllowNullable(FetchedCart::giftCardUuid),
AllowNullable(FetchedCart::giftCardRedemption),
AllowNullable(FetchedCart::totalBeforeGiftCardRedemption),
IgnoreNullable(FetchedCart::utmData),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ val fetchedOrderNullablePropertyRules: List<NullablePropertyRule<*, *>> = listOf
AllowNullable(FetchedOrder::giftCardCode),
AllowNullable(FetchedOrder::giftCardDoubleSpending),
AllowNullable(FetchedOrder::giftCardId),
AllowNullable(FetchedOrder::giftCardUuid),
AllowNullable(FetchedOrder::giftCardRedemption),
AllowNullable(FetchedOrder::globalReferer),
AllowNullable(FetchedOrder::handlingFee),
Expand Down Expand Up @@ -318,5 +319,6 @@ val fetchedOrderNullablePropertyRules: List<NullablePropertyRule<*, *>> = listOf
AllowNullable(FetchedOrder.Loyalty::redemption),
AllowNullable(FetchedOrder.LoyaltyRedemption::id),
AllowNullable(FetchedOrder.LoyaltyRedemption::amount),
AllowNullable(FetchedOrder.LoyaltyRedemption::cancelled),
AllowNullable(FetchedOrder::customerFiscalCode),
)
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ val orderForCalculateNullablePropertyRules: List<NullablePropertyRule<*, *>> = l
AllowNullable(OrderForCalculate::handlingFee),
AllowNullable(OrderForCalculate::giftCardCode),
AllowNullable(OrderForCalculate::giftCardId),
AllowNullable(OrderForCalculate::giftCardUuid),
AllowNullable(OrderForCalculate::giftCardTransactionOrderId),
AllowNullable(OrderForCalculate::giftCardRedemption),
AllowNullable(OrderForCalculate::totalBeforeGiftCardRedemption),
Expand Down

0 comments on commit 0f23e56

Please sign in to comment.