package com.sebastian.sokolowski.auctionhunter.soap;

import com.alexgilleran.icesoap.observer.SOAP11Observer;
import com.alexgilleran.icesoap.observer.SOAPObserver;
import com.alexgilleran.icesoap.request.Request;
import com.alexgilleran.icesoap.request.RequestFactory;
import com.alexgilleran.icesoap.request.SOAP11Request;
import com.alexgilleran.icesoap.request.impl.RequestFactoryImpl;
import com.sebastian.sokolowski.auctionhunter.soap.envelopes.DoGetCatsDataCountEnvelope;
import com.sebastian.sokolowski.auctionhunter.soap.envelopes.DoGetCatsDataLimitEnvelope;
import com.sebastian.sokolowski.auctionhunter.soap.envelopes.DoGetItemsListEnvelope;
import com.sebastian.sokolowski.auctionhunter.soap.fault.AllegroSOAPFault;
import com.sebastian.sokolowski.auctionhunter.soap.response.doGetCatsDataCountResponse.DoGetCatsDataCountResponse;
import com.sebastian.sokolowski.auctionhunter.soap.response.doGetCatsDataLimitResponse.DoGetCatsDataLimitResponse;
import com.sebastian.sokolowski.auctionhunter.soap.response.doGetItemsListResponse.DoGetItemsListResponse;

/**
 * Created by Sebastain Sokołowski on 19.02.17.
 */

public class RequestManager {
    private final static String TAG = RequestManager.class.getSimpleName();
    private final String URL = "https://webapi.allegro.pl/service.php";
    private final RequestFactory requestFactory = new RequestFactoryImpl();

    public void deGetItemsList(DoGetItemsListEnvelope doGetItemsListEnvelope, SOAP11Observer<DoGetItemsListResponse> doGetItemsListResponseSOAP11Observer) {
        SOAP11Request<DoGetItemsListResponse> definitionRequest = requestFactory.buildRequest(
                URL,
                doGetItemsListEnvelope.create(),
                "#doGetItemsList",
                DoGetItemsListResponse.class);
        definitionRequest.execute(doGetItemsListResponseSOAP11Observer);
    }

    public void doGetCatsDataCount(SOAP11Observer<DoGetCatsDataCountResponse> doGetCatsDataCountResponseSOAP11Observer) {
        SOAP11Request<DoGetCatsDataCountResponse> definitionRequest = requestFactory.buildRequest(
                URL,
                new DoGetCatsDataCountEnvelope(),
                "#doGetCatsDataCount",
                DoGetCatsDataCountResponse.class);
        definitionRequest.execute(doGetCatsDataCountResponseSOAP11Observer);
    }

    public void doGetCatsDataLimit(DoGetCatsDataLimitEnvelope doGetCatsDataLimitEnvelope, SOAPObserver<DoGetCatsDataLimitResponse, AllegroSOAPFault> doGetCatsDataLimitResponseSOAP11Observer) {
        Request<DoGetCatsDataLimitResponse, AllegroSOAPFault> definitionRequest = requestFactory.buildRequest(
                URL,
                doGetCatsDataLimitEnvelope.create(),
                "#doGetCatsDataLimit",
                DoGetCatsDataLimitResponse.class, AllegroSOAPFault.class);
        definitionRequest.execute(doGetCatsDataLimitResponseSOAP11Observer);
    }
}

@@ -51,65 +51,8 @@
 p;%0A%0A
-import com.alexgilleran.icesoap.observer.SOAP11Observer;%0A
 impo
@@ -211,63 +211,8 @@
 ry;%0A
-import com.alexgilleran.icesoap.request.SOAP11Request;%0A
 impo
@@ -1338,26 +1338,24 @@
 velope, SOAP
-11
 Observer%3CDoG
@@ -1369,24 +1369,42 @@
 ListResponse
+, AllegroSOAPFault
 %3E doGetItems
@@ -1407,38 +1407,52 @@
 temsListResponse
+AllegroSOAPFault
 SOAP
-11
 Observer) %7B%0A    
@@ -1447,38 +1447,32 @@
 rver) %7B%0A        
-SOAP11
 Request%3CDoGetIte
@@ -1477,32 +1477,50 @@
 temsListResponse
+, AllegroSOAPFault
 %3E definitionRequ
@@ -1695,32 +1695,56 @@
 stResponse.class
+, AllegroSOAPFault.class
 );%0A        defin
@@ -1778,38 +1778,52 @@
 temsListResponse
+AllegroSOAPFault
 SOAP
-11
 Observer);%0A    %7D
@@ -1859,26 +1859,24 @@
 taCount(SOAP
-11
 Observer%3CDoG
@@ -1898,16 +1898,34 @@
 Response
+, AllegroSOAPFault
 %3E doGetC
@@ -1936,38 +1936,52 @@
 ataCountResponse
+AllegroSOAPFault
 SOAP
-11
 Observer) %7B%0A    
@@ -1984,22 +1984,16 @@
         
-SOAP11
 Request%3C
@@ -2018,16 +2018,34 @@
 Response
+, AllegroSOAPFault
 %3E defini
@@ -2241,24 +2241,48 @@
 sponse.class
+, AllegroSOAPFault.class
 );%0A        d
@@ -2324,38 +2324,52 @@
 ataCountResponse
+AllegroSOAPFault
 SOAP
-11
 Observer);%0A    %7D
@@ -2537,38 +2537,52 @@
 ataLimitResponse
+AllegroSOAPFault
 SOAP
-11
 Observer) %7B%0A    
@@ -2940,14 +2940,28 @@
 onse
+AllegroSOAPFault
 SOAP
-11
 Obse

Add custom soap fault to all requests.