001/*
002 *   Copyright 2020 Vonage
003 *
004 *   Licensed under the Apache License, Version 2.0 (the "License");
005 *   you may not use this file except in compliance with the License.
006 *   You may obtain a copy of the License at
007 *
008 *        http://www.apache.org/licenses/LICENSE-2.0
009 *
010 *   Unless required by applicable law or agreed to in writing, software
011 *   distributed under the License is distributed on an "AS IS" BASIS,
012 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 *   See the License for the specific language governing permissions and
014 *   limitations under the License.
015 */
016package com.vonage.client.conversion;
017
018
019import com.vonage.client.*;
020
021import java.util.Date;
022
023/**
024 * A client for talking to the Vonage Conversion API. The standard way to obtain an instance of this class is to use
025 * {@link VonageClient#getConversionClient()}.
026 * <p>
027 * Allows you to tell Vonage about the reliability of your 2FA communications.
028 * <p>
029 * More information on method parameters can be found at Vonage website:
030 * <a href="https://developer.nexmo.com/messaging/conversion-api/overview">https://developer.nexmo.com/messaging/conversion-api/overview</a>
031 */
032public class ConversionClient extends AbstractClient {
033    private ConversionEndpoint conversionEndpoint;
034
035    public ConversionClient(HttpWrapper httpWrapper) {
036        super(httpWrapper);
037
038        this.conversionEndpoint = new ConversionEndpoint(httpWrapper);
039    }
040
041    /**
042     * Submit a request to the Conversion API indicating whether or not a message was delivered.
043     *
044     * @param type      The {@link ConversionRequest.Type} type of com.vonage.client.conversion.
045     * @param messageId The id of the message that was sent.
046     * @param delivered A boolean indicating whether or not it was delivered.
047     * @param timestamp A timestamp of when it was known to be delivered.
048     *
049     * @throws VonageClientException        if there was a problem with the Vonage request or response objects.
050     * @throws VonageResponseParseException if the response from the API could not be parsed.
051     */
052    public void submitConversion(ConversionRequest.Type type,
053                                 String messageId,
054                                 boolean delivered,
055                                 Date timestamp) throws VonageResponseParseException, VonageClientException {
056        this.conversionEndpoint.submitConversion(new ConversionRequest(type, messageId, delivered, timestamp));
057    }
058}