Search in sources :

Example 51 with SneakyThrows

use of lombok.SneakyThrows in project instagram4j by brunocvcunha.

the class InstagramLoginTwoFactorRequest method getPayload.

@Override
@SneakyThrows
public String getPayload() {
    ObjectMapper mapper = new ObjectMapper();
    String payloadJson = mapper.writeValueAsString(payload);
    return payloadJson;
}
Also used : ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) SneakyThrows(lombok.SneakyThrows)

Example 52 with SneakyThrows

use of lombok.SneakyThrows in project instagram4j by brunocvcunha.

the class InstagramPostCommentRequest method getPayload.

@Override
@SneakyThrows
public String getPayload() {
    Map<String, Object> likeMap = new LinkedHashMap<>();
    likeMap.put("_uuid", api.getUuid());
    likeMap.put("_uid", api.getUserId());
    likeMap.put("_csrftoken", api.getOrFetchCsrf());
    likeMap.put("comment_text", commentText);
    ObjectMapper mapper = new ObjectMapper();
    String payloadJson = mapper.writeValueAsString(likeMap);
    return payloadJson;
}
Also used : ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) LinkedHashMap(java.util.LinkedHashMap) SneakyThrows(lombok.SneakyThrows)

Example 53 with SneakyThrows

use of lombok.SneakyThrows in project instagram4j by brunocvcunha.

the class InstagramRequest method parseJson.

/**
 * Parses Json into type
 * @param str Entity content
 * @param clazz Class
 * @return Result
 */
@SneakyThrows
public <U> U parseJson(String str, Class<U> clazz) {
    if (log.isInfoEnabled()) {
        if (log.isDebugEnabled()) {
            log.debug("Reading " + clazz.getSimpleName() + " from " + str);
        } else {
            String printStr = str;
            if (printStr.length() > 128) {
                printStr = printStr.substring(0, 128);
            }
            log.info("Reading " + clazz.getSimpleName() + " from " + printStr);
        }
    }
    ObjectMapper objectMapper = new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false).configure(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true);
    return objectMapper.readValue(str, clazz);
}
Also used : ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) SneakyThrows(lombok.SneakyThrows)

Example 54 with SneakyThrows

use of lombok.SneakyThrows in project instagram4j by brunocvcunha.

the class InstagramExposeRequest method getPayload.

@Override
@SneakyThrows
public String getPayload() {
    Map<String, Object> likeMap = new LinkedHashMap<>();
    likeMap.put("_uuid", api.getUuid());
    likeMap.put("_uid", api.getUserId());
    likeMap.put("id", api.getUserId());
    likeMap.put("_csrftoken", api.getOrFetchCsrf());
    likeMap.put("experiment", "ig_android_profile_contextual_feed");
    ObjectMapper mapper = new ObjectMapper();
    String payloadJson = mapper.writeValueAsString(likeMap);
    return payloadJson;
}
Also used : ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) LinkedHashMap(java.util.LinkedHashMap) SneakyThrows(lombok.SneakyThrows)

Example 55 with SneakyThrows

use of lombok.SneakyThrows in project instagram4j by brunocvcunha.

the class InstagramZeroRatingTokenRequest method getPayload.

@Override
@SneakyThrows
public String getPayload() {
    Map<String, Object> likeMap = new LinkedHashMap<>();
    likeMap.put("token_hash", "");
    ObjectMapper mapper = new ObjectMapper();
    String payloadJson = mapper.writeValueAsString(likeMap);
    return payloadJson;
}
Also used : ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) LinkedHashMap(java.util.LinkedHashMap) SneakyThrows(lombok.SneakyThrows)

Aggregations

SneakyThrows (lombok.SneakyThrows)706 lombok.val (lombok.val)314 Test (org.junit.Test)91 ArrayList (java.util.ArrayList)75 HashMap (java.util.HashMap)63 List (java.util.List)53 Cleanup (lombok.Cleanup)38 Map (java.util.Map)35 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)34 Collectors (java.util.stream.Collectors)34 LinkedHashMap (java.util.LinkedHashMap)30 File (java.io.File)28 Path (java.nio.file.Path)28 IOException (java.io.IOException)26 InputStream (java.io.InputStream)24 Slf4j (lombok.extern.slf4j.Slf4j)24 URL (java.net.URL)22 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)22 Collection (java.util.Collection)18 FishingActivityQuery (eu.europa.ec.fisheries.ers.service.search.FishingActivityQuery)17