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

Add support for shop services (APPS-1039) #220

Merged
merged 2 commits into from
Nov 20, 2024
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 CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 15 additions & 2 deletions core/src/main/java/io/snabble/sdk/Shop.java
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,8 @@ public String toString() {
private CustomerNetwork[] customerNetworks;
private OpeningHourSpecification[] openingHoursSpecification;
private JsonElement external;
@SerializedName("shopServices")
private ShopServices[] shopServices;

Shop() {
// for gson
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand All @@ -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;
}

Expand Down Expand Up @@ -369,6 +381,7 @@ public String toString() {
", customerNetworks=" + Arrays.toString(customerNetworks) +
", openingHoursSpecification=" + Arrays.toString(openingHoursSpecification) +
", external=" + external +
", shopServices=" + Arrays.toString(shopServices) +
'}';
}

Expand Down Expand Up @@ -401,4 +414,4 @@ public Shop[] newArray(int size) {
return new Shop[size];
}
};
}
}
37 changes: 37 additions & 0 deletions core/src/main/java/io/snabble/sdk/ShopServices.kt
Original file line number Diff line number Diff line change
@@ -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?
)
}
Loading