All Downloads are FREE. Search and download functionalities are using the official Maven repository.

ru.dezhik.sms.sender.api.smsru.status.SMSRuStatusHandler Maven / Gradle / Ivy

There is a newer version: 0.1.3
Show newest version
package ru.dezhik.sms.sender.api.smsru.status;

import java.util.List;
import java.util.StringTokenizer;

import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;

import ru.dezhik.sms.sender.RequestValidationException;
import ru.dezhik.sms.sender.api.smsru.AbstractSMSRuApiHandler;
import ru.dezhik.sms.sender.api.smsru.SMSRuApiResponse;

/**
 * @author ilya.dezhin
 */
public class SMSRuStatusHandler extends AbstractSMSRuApiHandler {
    @Override
    public String getMethodPath() {
        return "/sms/status";
    }

    @Override
    public void validate(SMSRuStatusRequest request) throws IllegalArgumentException {
        if (request.getId() == null || request.getId().isEmpty()) {
            throw new RequestValidationException("SMS id can't be empty.");
        }
    }

    @Override
    public void appendParams(SMSRuStatusRequest request, List params) {
        params.add(new BasicNameValuePair("id", request.getId()));
    }

    @Override
    public SMSRuApiResponse parseResponse(SMSRuStatusRequest request, String responseStr) {
        final SMSRuApiResponse response = new SMSRuApiResponse();
        StringTokenizer tokenizer = tokenizeResponse(responseStr);
        parseAndSetStatus(request, response, tokenizer);
        return response;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy