From 39b48108f09db82ded380c9ebe09c8127a3c30ff Mon Sep 17 00:00:00 2001 From: Christian Maier Date: Mon, 18 Nov 2024 16:43:22 +0100 Subject: [PATCH 1/2] WIP: Add shop services provided by the meta data --- core/src/main/java/io/snabble/sdk/Shop.java | 17 ++++++++- .../main/java/io/snabble/sdk/ShopServices.kt | 37 +++++++++++++++++++ 2 files changed, 52 insertions(+), 2 deletions(-) create mode 100644 core/src/main/java/io/snabble/sdk/ShopServices.kt diff --git a/core/src/main/java/io/snabble/sdk/Shop.java b/core/src/main/java/io/snabble/sdk/Shop.java index 0f387fb0c3..a87fe0a957 100644 --- a/core/src/main/java/io/snabble/sdk/Shop.java +++ b/core/src/main/java/io/snabble/sdk/Shop.java @@ -162,6 +162,8 @@ public String toString() { private CustomerNetwork[] customerNetworks; private OpeningHourSpecification[] openingHoursSpecification; private JsonElement external; + @SerializedName("shopServices") + private ShopServices[] shopServices; Shop() { // for gson @@ -299,6 +301,14 @@ public JsonElement getExternal() { return external; } + /** + * Returns the shop related on-site services for the customer + */ + @NonNull + public ShopServices[] getShopServices() { + return shopServices; + } + static Shop[] fromJson(JsonElement json) { try { return GsonHolder.get().fromJson(json, Shop[].class); @@ -329,7 +339,8 @@ public boolean equals(Object o) { Objects.equals(links, shop.links) && Arrays.equals(customerNetworks, shop.customerNetworks) && Arrays.equals(openingHoursSpecification, shop.openingHoursSpecification) && - Objects.equals(external, shop.external); + Objects.equals(external, shop.external) && + Arrays.equals(shopServices, shop.shopServices); } @Override @@ -338,6 +349,7 @@ public int hashCode() { result = 31 * result + Arrays.hashCode(services); result = 31 * result + Arrays.hashCode(customerNetworks); result = 31 * result + Arrays.hashCode(openingHoursSpecification); + result = 31 * result + Arrays.hashCode(shopServices); return result; } @@ -369,6 +381,7 @@ public String toString() { ", customerNetworks=" + Arrays.toString(customerNetworks) + ", openingHoursSpecification=" + Arrays.toString(openingHoursSpecification) + ", external=" + external + + ", shopServices=" + Arrays.toString(shopServices) + '}'; } @@ -401,4 +414,4 @@ public Shop[] newArray(int size) { return new Shop[size]; } }; -} \ No newline at end of file +} diff --git a/core/src/main/java/io/snabble/sdk/ShopServices.kt b/core/src/main/java/io/snabble/sdk/ShopServices.kt new file mode 100644 index 0000000000..af4d0a971a --- /dev/null +++ b/core/src/main/java/io/snabble/sdk/ShopServices.kt @@ -0,0 +1,37 @@ +package io.snabble.sdk + +import com.google.gson.annotations.SerializedName + +/** + * Shop related on-site services + */ +data class ShopServices( + /** + * Url for the service related icon. + * + * The URL might be empty! + */ + @SerializedName("iconURL") val iconPath: String, + + /** + * Descriptions for the services in the language de and en. + */ + @SerializedName("translations") val descriptions: Descriptions, +) { + + data class Descriptions( + /** + * Description in the language de. + * + * This value might be empty! + */ + @SerializedName("de") val german: String?, + + /** + * Description in the language en. + * + * This value might be empty! + */ + @SerializedName("en") val english: String? + ) +} From 518580f964a523934c82888cf498aeaa90eeb23f Mon Sep 17 00:00:00 2001 From: Christian Maier Date: Tue, 19 Nov 2024 13:55:46 +0100 Subject: [PATCH 2/2] Update CHANGELOG --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index be0d74dc9f..a94a1e1bc9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ All notable changes to this project will be documented in this file. ### Removed ### Fixed +## [0.79.0] +### Added +* core: Add the shop services from meta data to Shop class + ## [0.78.0] ### Added * core: Add the `isSuccessful` state to orders/receipts