Search in sources :

Example 1 with Offer

use of amosalexa.services.pricequery.aws.model.Offer in project amos-ss17-alexa by c-i-ber.

the class PriceQueryService method getProductInformation.

private SpeechletResponse getProductInformation(Intent intent, Session session) {
    // get keyword for product search
    Slot slot = intent.getSlot("ProductKeyword");
    String keyword = slot.getValue();
    String speechTextStart = "";
    String speechText;
    if (keyword != null) {
        log.warn(getClass().toString() + " Keyword: " + keyword);
        List<Item> items = AWSLookup.itemSearch(keyword, 1, null);
        if (!items.isEmpty()) {
            speechTextStart = "Bingo, Ich habe etwas gefunden!";
        }
        String specheTextItems = "";
        for (int i = 0; i < 3; i++) {
            Offer offer = AWSLookup.offerLookup(items.get(i).getASIN());
            specheTextItems = specheTextItems + AWSUtil.shortTitle(items.get(i).getTitle()) + "fuer " + offer.getLowestNewPrice() / 100 + " Euro";
        }
        speechText = speechTextStart + specheTextItems;
    } else {
        speechText = speechTextWelcome;
    }
    return getSpeechletResponse(speechText, repromptTextWelcome);
}
Also used : Item(amosalexa.services.pricequery.aws.model.Item) Offer(amosalexa.services.pricequery.aws.model.Offer) Slot(com.amazon.speech.slu.Slot)

Example 2 with Offer

use of amosalexa.services.pricequery.aws.model.Offer in project amos-ss17-alexa by c-i-ber.

the class OfferCreator method createOffer.

public static Offer createOffer() {
    Offer offer = new Offer();
    offer.setAsin(asin);
    /** Offer Summary **/
    java.util.Date date = new java.util.Date();
    Timestamp timestamp = new Timestamp(date.getTime());
    offer.setTime(timestamp);
    String lowestNewPrice = XMLParser.readValue(offerSummaryXML, new String[] { "LowestNewPrice", "Amount" });
    if (AWSUtil.isNumeric(lowestNewPrice)) {
        offer.setLowestNewPrice(Integer.parseInt(lowestNewPrice));
    }
    String currencyCode = XMLParser.readValue(offerSummaryXML, new String[] { "LowestNewPrice", "CurrencyCode" });
    offer.setCurrencyCode(currencyCode);
    String lowestUsedPrice = XMLParser.readValue(offerSummaryXML, new String[] { "LowestUsedPrice" });
    if (AWSUtil.isNumeric(lowestUsedPrice)) {
        offer.setLowestUsedPrice(Integer.parseInt(lowestUsedPrice));
    }
    String totalNew = XMLParser.readValue(offerSummaryXML, new String[] { "TotalNew" });
    if (AWSUtil.isNumeric(totalNew)) {
        offer.setTotalNew(Integer.parseInt(totalNew));
    }
    String totalUsed = XMLParser.readValue(offerSummaryXML, new String[] { "TotalUsed" });
    if (AWSUtil.isNumeric(totalUsed)) {
        offer.setTotalUsed(Integer.parseInt(totalUsed));
    }
    /** Offers **/
    String offerListingId = XMLParser.readValue(offers, new String[] { "OfferListingId" });
    offer.setOfferListingId(offerListingId);
    String amazonNewPrice = XMLParser.readValue(offers, new String[] { "Price", "Amount" });
    if (AWSUtil.isNumeric(amazonNewPrice)) {
        offer.setAmazonNewPrice(Integer.parseInt(amazonNewPrice));
    }
    String amazonAmountSaved = XMLParser.readValue(offers, new String[] { "AmountSaved", "Amount" });
    if (AWSUtil.isNumeric(amazonAmountSaved)) {
        offer.setAmazonAmountSaved(Integer.parseInt(amazonAmountSaved));
    }
    String availability = XMLParser.readValue(offers, new String[] { "Availability" });
    if (availability.length() < 50) {
        offer.setAmazonAvailability(availability);
    }
    String eligibleForSuperSaverShipping = XMLParser.readValue(offers, new String[] { "IsEligibleForSuperSaverShipping" });
    offer.setEligibleForSuperSaverShipping(eligibleForSuperSaverShipping.equals("1"));
    String eligibleForPrime = XMLParser.readValue(offers, new String[] { "IsEligibleForPrime" });
    offer.setEligibleForPrime(eligibleForPrime.equals("1"));
    return offer;
}
Also used : Offer(amosalexa.services.pricequery.aws.model.Offer) Timestamp(java.sql.Timestamp)

Aggregations

Offer (amosalexa.services.pricequery.aws.model.Offer)2 Item (amosalexa.services.pricequery.aws.model.Item)1 Slot (com.amazon.speech.slu.Slot)1 Timestamp (java.sql.Timestamp)1