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

org.ctoolkit.restapi.client.pubsub.adaptee.ModifyPushConfigAdaptee Maven / Gradle / Ivy

There is a newer version: 0.38
Show newest version
/*
 * Copyright (c) 2017 Comvai, s.r.o. All Rights Reserved.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 */

package org.ctoolkit.restapi.client.pubsub.adaptee;

import com.google.api.services.pubsub.Pubsub;
import com.google.api.services.pubsub.model.ModifyPushConfigRequest;
import org.ctoolkit.restapi.client.Identifier;
import org.ctoolkit.restapi.client.adaptee.MediaProvider;
import org.ctoolkit.restapi.client.adaptee.UpdateExecutorAdaptee;
import org.ctoolkit.restapi.client.adapter.AbstractGoogleClientAdaptee;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.inject.Inject;
import javax.inject.Provider;
import javax.inject.Singleton;
import java.io.IOException;
import java.util.Locale;
import java.util.Map;

/**
 * The Pub/Sub's {@link ModifyPushConfigRequest} adaptee implementation.
 *
 * @author Aurel Medvegy
 */
@Singleton
public class ModifyPushConfigAdaptee
        extends AbstractGoogleClientAdaptee
        implements UpdateExecutorAdaptee
{
    @Inject
    public ModifyPushConfigAdaptee( Provider client )
    {
        super( client );
    }

    @Override
    public Object prepareUpdate( @Nonnull ModifyPushConfigRequest resource,
                                 @Nonnull Identifier identifier,
                                 @Nullable MediaProvider provider )
            throws IOException
    {
        return client().projects().subscriptions().modifyPushConfig( identifier.getString(), resource );
    }

    @Override
    public Object executeUpdate( @Nonnull Object request,
                                 @Nullable Map parameters,
                                 @Nullable Locale locale )
            throws IOException
    {
        execute( request, parameters );
        // means if successful, the response body will be empty
        return null;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy