com.apitrary.api.transport.Transport Maven / Gradle / Ivy
/*
* Copyright 2012-2013 Denis Neuling
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.apitrary.api.transport;
import java.net.URI;
import com.apitrary.api.ApitraryApi;
import com.apitrary.api.exception.ApiTransportException;
/**
* Single argumentless constructor is needed! Otherwise we cannot instantiate
* reflectively the new transport instance.
*
* @author Denis Neuling ([email protected])
*
* @since 0.1.1
*/
public abstract class Transport {
/** Constant apiAuthHeaderKey="X-Api-Key"
*/
protected static final String apiAuthHeaderKey = "X-Api-Key";
/** Constant contentType="application/json"
*/
protected static final String contentType = "application/json";
private ApitraryApi apitraryApi;
/**
* Constructor for Transport.
*/
public Transport() {
}
/**
* Constructor for Transport.
*
* @param apitraryApi a {@link com.apitrary.api.ApitraryApi} object.
*/
public Transport(ApitraryApi apitraryApi) {
this.apitraryApi = apitraryApi;
}
/**
* Getter for the field apitraryApi
.
*
* @return a {@link com.apitrary.api.ApitraryApi} object.
*/
public ApitraryApi getApitraryApi() {
return apitraryApi;
}
/**
* Setter for the field apitraryApi
.
*
* @param apitraryApi a {@link com.apitrary.api.ApitraryApi} object.
*/
public void setApitraryApi(ApitraryApi apitraryApi) {
this.apitraryApi = apitraryApi;
}
/**
* doGet.
*
* @param uri a {@link java.net.URI} object.
* @return a {@link com.apitrary.api.transport.TransportResult} object.
* @throws com.apitrary.api.exception.ApiTransportException if any.
*/
public abstract TransportResult doGet(URI uri) throws ApiTransportException;
/**
* doPost.
*
* @param uri a {@link java.net.URI} object.
* @param payload a {@link java.lang.String} object.
* @return a {@link com.apitrary.api.transport.TransportResult} object.
* @throws com.apitrary.api.exception.ApiTransportException if any.
*/
public abstract TransportResult doPost(URI uri, String payload) throws ApiTransportException;
/**
* doPut.
*
* @param uri a {@link java.net.URI} object.
* @param payload a {@link java.lang.String} object.
* @return a {@link com.apitrary.api.transport.TransportResult} object.
* @throws com.apitrary.api.exception.ApiTransportException if any.
*/
public abstract TransportResult doPut(URI uri, String payload) throws ApiTransportException;
/**
* doDelete.
*
* @param uri a {@link java.net.URI} object.
* @return a {@link com.apitrary.api.transport.TransportResult} object.
* @throws com.apitrary.api.exception.ApiTransportException if any.
*/
public abstract TransportResult doDelete(URI uri) throws ApiTransportException;
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy