ContactsResource extends Resource { public CallSpec<InvitationStats, HttpError> inviteByMail(String... emails) { return Resource.<InvitationStats, HttpError>newPostSpec(api, "/v1/users/invite", true) .queryParam("to_emails", emails) .responseAs(single(InvitationStats.class, "invitation_stats")) .build(); } ContactsResource(XingApi api); CallSpec<List<XingUser>, HttpError> getUserContacts(String userId); CallSpec<List<XingUser>, HttpError> getOwnContacts(); CallSpec<List<String>, HttpError> getOwnContactsIds(); CallSpec<List<String>, HttpError> getAssignedTags(String userId, String contactId); CallSpec<List<String>, HttpError> getOwnAssignedTags(String contactId); CallSpec<List<XingUser>, HttpError> getSharedContacts(String userId); @Experimental CallSpec<List<XingUser>, HttpError> getUpcomingBirthdays(); CallSpec<List<ContactRequest>, HttpError> getIncomingContactRequests(); CallSpec<List<PendingContactRequest>, HttpError> getPendingContactRequests(); CallSpec<Void, HttpError> sendContactRequest(String userId); CallSpec<Void, HttpError> acceptContactRequest(String recipientId, String senderId); CallSpec<Void, HttpError> revokeContactRequest(String recipientId, String senderId); CallSpec<ContactPaths, HttpError> getContactPaths(String userId, String otherUserId); CallSpec<InvitationStats, HttpError> inviteByMail(String... emails);  }
@Test public void inviteByMail() throws Exception { server.enqueue(new MockResponse().setBody("{\n" + " \"invitation_stats\": {\n" + " \"total_addresses\": 7,\n" + " \"invitations_sent\": 3,\n" + " \"already_invited\": [\n" + " \"kven.sever@example.net\"\n" + " ],\n" + " \"already_member\": [\n" + " {\n" + " \"id\": \"666666_abcdef\",\n" + " \"email\": \"sark.midt@xing.com\",\n" + " \"display_name\": \"Sark Midt\"\n" + " },\n" + " {\n" + " \"id\": \"12345_abcdef\",\n" + " \"email\": \"kennart.loopmann@xing.com\",\n" + " \"display_name\": \"Kennart Loopmann\"\n" + " }\n" + " ],\n" + " \"invalid_addresses\": [\n" + " \"@example.f\"\n" + " ]\n" + " }\n" + '}')); Response<InvitationStats, HttpError> response = resource.inviteByMail("test@test.test", "email").execute(); assertThat(response.body().getTotalAddresses()).isEqualTo(7); assertThat(response.body().getInvitationsSent()).isEqualTo(3); assertThat(response.body().getAlreadyInvited()).containsExactly("kven.sever@example.net"); assertThat(response.body().getInvalidAddresses()).containsExactly("@example.f"); assertThat(response.body().getAlreadyMember().size()).isEqualTo(2); }