Skip to content
This repository has been archived by the owner on Mar 6, 2024. It is now read-only.

added show many request #58

Merged
merged 1 commit into from
Nov 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package io.github.taz03.jia.friendships;

import static org.junit.jupiter.api.Assertions.assertEquals;

import io.github.taz03.jia.InstagramClient;
import io.github.taz03.jia.TestConfiguration;
import io.github.taz03.jia.requests.friendships.ShowManyRequest;
import io.github.taz03.jia.responses.friendships.ShowManyResponse;

import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit.jupiter.SpringExtension;

@ExtendWith(SpringExtension.class)
@ContextConfiguration(classes = TestConfiguration.class)
public final class ShowManyTest {
@Autowired
private InstagramClient client;

@Autowired
private long instagramPk;

@Test
public void showManyTest() throws Exception {
ShowManyRequest request = new ShowManyRequest(instagramPk);
ShowManyResponse response = client.sendRequest(request).get();

assertEquals("ok", response.getStatus());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package io.github.taz03.jia.requests.friendships;

import java.util.Arrays;
import java.util.Map;
import java.util.stream.Collectors;

import io.github.taz03.jia.requests.InstagramPostRequest;
import io.github.taz03.jia.responses.friendships.ShowManyResponse;

/**
* Represents an Instagram show many request, used to show multiple connections in same request.
*
* @see io.github.taz03.jia.requests.friendships.ShowRequest
*/
public final class ShowManyRequest extends InstagramPostRequest<ShowManyResponse> {
/**
* Creates an Instagram show many request.
*
* @param userIds pk of the users to show the connections to
*/
public ShowManyRequest(long... userIds) {
super(ShowManyResponse.class, "/api/v1/friendships/show_many/", null, Map.of(
"user_ids", Arrays.stream(userIds).mapToObj(String::valueOf).collect(Collectors.joining(","))
));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

/**
* Represents an Instagram request, used to show your connection info with others.
*
* @see io.github.taz03.jia.requests.friendships.ShowManyRequest
*/
public final class ShowRequest extends InstagramGetRequest<ShowResponse> {
/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package io.github.taz03.jia.responses.friendships;

import java.util.Map;

import io.github.taz03.jia.responses.InstagramResponse;
import io.github.taz03.jia.responses.models.friendships.Status;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;

@JsonIgnoreProperties(ignoreUnknown = true)
public final class ShowManyResponse extends InstagramResponse {
@JsonProperty("friendship_statuses")
Map<String, Status> statuses;

public Map<String, Status> getStatuses() {
return statuses;
}

@Override
public String toString() {
return "ShowManyResponse{" + "statuses=" + statuses + '}';
}
}