package com.youcruit.mailchimp.client;

import java.io.IOException;

import com.youcruit.mailchimp.client.http.HttpClient;
import com.youcruit.mailchimp.client.http.HttpClient.Method;
import com.youcruit.mailchimp.client.objects.pojos.request.list.GetListRequest;
import com.youcruit.mailchimp.client.objects.pojos.request.list.ListCreateMemberRequest;
import com.youcruit.mailchimp.client.objects.pojos.request.list.ListMemberRequest;
import com.youcruit.mailchimp.client.objects.pojos.request.list.ListMembersRequest;
import com.youcruit.mailchimp.client.objects.pojos.request.list.ListsRequest;
import com.youcruit.mailchimp.client.objects.pojos.response.list.ListMemberResponse;
import com.youcruit.mailchimp.client.objects.pojos.response.list.ListMembersResponse;
import com.youcruit.mailchimp.client.objects.pojos.response.list.ListResponse;
import com.youcruit.mailchimp.client.objects.pojos.response.list.ListsResponse;
import com.youcruit.mailchimp.client.serializers.MD5TypeAdapter;

public class ListClient {

    private final HttpClient httpClient;

    public ListClient(final HttpClient httpClient) {
	this.httpClient = httpClient;
    }

    public ListsResponse getLists(ListsRequest request) throws IOException {
	return httpClient.sync(Method.GET, ListsResponse.class, httpClient.toQueryParameters(request), "lists");
    }

    public ListResponse getList(String id, GetListRequest request) throws IOException {
	return httpClient.sync(Method.GET, ListResponse.class, httpClient.toQueryParameters(request), "lists", id);
    }

    public ListMembersResponse getListMembers(String id, ListMembersRequest request) throws IOException {
	return httpClient.sync(Method.GET, ListMembersResponse.class, httpClient.toQueryParameters(request), "lists", id, "members");
    }

    public ListMemberResponse getListMember(String id, String email, ListMemberRequest request) throws IOException {
	return httpClient.sync(Method.GET, ListMemberResponse.class, httpClient.toQueryParameters(request), "lists", id, "members", new MD5TypeAdapter().toMD5LowerCase(email));
    }
    
    public ListMemberResponse createListMember(String id, ListCreateMemberRequest request) throws IOException {
	return httpClient.sync(request, Method.POST, ListMemberResponse.class, "lists", id, "members");
    }

}
@@ -2074,20 +2074,16 @@
 ;%0A    %7D%0A
-    
 %0A    pub
@@ -2291,9 +2291,208 @@
 %0A    %7D%0A%0A
+    public void deleteListMember(String id, String email) throws IOException %7B%0A%09httpClient.sync(Method.DELETE, Void.class, %22lists%22, id, %22members%22, new MD5TypeAdapter().toMD5LowerCase(email));%0A    %7D%0A%0A
 %7D

Delete member