package com.fractalite.amad_ndc.convertersRQ;



import com.amadeus.travelManagement.amadeus.xml._2010._06.travel_orderretrieverq_v1.AMATravelOrderRetrieveRQ;
import com.amadeus.travelManagement.amadeus.xml._2010._06.travel_orderretrieverq_v1.PartyType;
import com.amadeus.travelManagement.amadeus.xml._2010._06.travel_orderretrieverq_v1.*;

import org.springframework.stereotype.Component;

@Component
public class AMA_TravelOrderRetrieveBuilder {

    public AMATravelOrderRetrieveRQ buildOrderRetriveRequest(String orgId,String ref) throws Exception {

        AMATravelOrderRetrieveRQ orderRetrieveRQ=new AMATravelOrderRetrieveRQ();

        orderRetrieveRQ.setParty(buildParty("unused","unused"));

        //build request
        RequestType requestType= new RequestType();
        OrderFilterCriteriaType orderFilterCriteria=new OrderFilterCriteriaType();
        BookingRefType bookingRef=new BookingRefType();
        BookingEntityType bookingEntity=new BookingEntityType();
        OrgType org=new OrgType();
        org.setOrgID(orgId);
        bookingEntity.setOrg(org);
        bookingRef.setBookingEntity(bookingEntity);
        bookingRef.setBookingID(ref);
        orderFilterCriteria.setBookingRefFilterCriteria(bookingRef);

        requestType.setOrderFilterCriteria(orderFilterCriteria);

        orderRetrieveRQ.setRequest(requestType);

        return orderRetrieveRQ;

    }



    public PartyType buildParty(String agencyID, String pseudoCityID){
        PartyType party=new PartyType();
        SenderType sender=new SenderType();
        TravelAgencyType travelAgency=new TravelAgencyType();
        travelAgency.setAgencyID(agencyID);
        travelAgency.setPseudoCityID(pseudoCityID);
        sender.setTravelAgency(travelAgency);
        party.setSender(sender);

        return party;
    }

}
