Subversion Repositories SmartDukaan

Rev

Rev 37321 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 37321 Rev 37388
Line 102... Line 102...
102
            }
102
            }
103
        }
103
        }
104
        return this.execute(request);
104
        return this.execute(request);
105
    }
105
    }
106
 
106
 
-
 
107
    /**
-
 
108
     * GET that returns the response body whatever the status code, rather than throwing and discarding
-
 
109
     * it as {@link #get(String, Map, Map)} does.
-
 
110
     *
-
 
111
     * <p>Use this against APIs that report their errors in a JSON body: with {@code get} a rejected
-
 
112
     * request surfaces as an exception carrying no detail, so the reason for the failure is lost. This
-
 
113
     * is the GET counterpart of {@link #postJson(String, Object, Map)}.</p>
-
 
114
     */
-
 
115
    public String getJson(String url, Map<String, String> params, Map<String, String> headers)
-
 
116
            throws ProfitMandiBusinessException, HttpHostConnectException {
-
 
117
        UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(url);
-
 
118
        if (params != null) {
-
 
119
            Set<String> keys = params.keySet();
-
 
120
            for (String key : keys) {
-
 
121
                builder.queryParam(key, params.get(key));
-
 
122
            }
-
 
123
        }
-
 
124
        HttpGet request = new HttpGet(builder.build().encode().toUri());
-
 
125
        if (headers != null) {
-
 
126
            for (Map.Entry<String, String> entry : headers.entrySet()) {
-
 
127
                request.setHeader(entry.getKey(), entry.getValue());
-
 
128
            }
-
 
129
        }
-
 
130
        return this.executeJson(request);
-
 
131
    }
-
 
132
 
107
    public MandiiResponse getMandii(String url, Map<String, String> params, Map<String, String> headers)
133
    public MandiiResponse getMandii(String url, Map<String, String> params, Map<String, String> headers)
108
            throws ProfitMandiBusinessException, HttpHostConnectException {
134
            throws ProfitMandiBusinessException, HttpHostConnectException {
109
        UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(url);
135
        UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(url);
110
        if (params != null) {
136
        if (params != null) {
111
            Set<String> keys = params.keySet();
137
            Set<String> keys = params.keySet();