// Path: src/main/java/com/codereligion/bugsnag/logback/model/NotificationVO.java
// public class NotificationVO {
// 
//     /**
//      * The api key associated with the project. Informs bugsnag which project has generated this error.
//      */
//     private String apiKey;
// 
//     /**
//      * This object describes the notifier itself. These properties are used
//      * within bugsnag to track error rates from a notifier.
//      */
//     private NotifierVO notifier = new NotifierVO();
// 
//     /**
//      * A list of error events that bugsnag should be notified of. In the current version of his notifier
//      * the list will contain only one event.
//      */
//     private List<EventVO> events = Lists.newArrayList();
// 
//     public String getApiKey() {
//         return apiKey;
//     }
// 
//     public void setApiKey(final String apiKey) {
//         this.apiKey = apiKey;
//     }
// 
//     public List<EventVO> getEvents() {
//         return events;
//     }
// 
//     public void addEvents(final List<EventVO> events) {
//         this.events.addAll(events);
//     }
// 
//     public NotifierVO getNotifier() {
//         return notifier;
//     }
// }
// 
// Path: src/main/java/com/codereligion/bugsnag/logback/resource/GsonMessageBodyWriter.java
// @Provider
// @Produces(MediaType.APPLICATION_JSON)
// public class GsonMessageBodyWriter implements MessageBodyWriter<Object> {
// 
//     private final Gson gson;
// 
//     /**
//      * Creates a new instance using the given {@code gson} for serialization.
//      * @param gson the {@link Gson} object to use
//      */
//     public GsonMessageBodyWriter(final Gson gson) {
//         this.gson = gson;
//     }
// 
//     @Override
//     public boolean isWriteable(
//             final Class<?> type,
//             final Type genericType,
//             final Annotation[] annotations,
//             final MediaType mediaType) {
//         return true;
//     }
// 
//     @Override
//     public long getSize(
//             final Object object,
//             final Class<?> type,
//             final Type genericType,
//             final Annotation[] annotations,
//             final MediaType mediaType) {
//         return -1;
//     }
// 
//     @Override
//     public void writeTo(
//             final Object object,
//             final Class<?> type,
//             final Type genericType,
//             final Annotation[] annotations,
//             final MediaType mediaType,
//             final MultivaluedMap<String, Object> httpHeaders,
//             final OutputStream entityStream) throws IOException {
// 
//         final OutputStreamWriter writer = new OutputStreamWriter(entityStream, Charsets.UTF_8);
// 
//         try {
//             gson.toJson(object, type, writer);
//         } finally {
//             writer.close();
//         }
//     }
// }
// 
// Path: src/main/java/com/codereligion/bugsnag/logback/resource/GsonProvider.java
// public class GsonProvider {
// 
//     private final Gson gson;
// 
//     /**
//      * Creates a new instance with the given {@code jsonFilterProvider}.
//      *
//      * @param jsonFilterProvider the {@link JsonFilterProvider} implementation to use
//      */
//     public GsonProvider(final JsonFilterProvider jsonFilterProvider) {
//         this.gson = new GsonBuilder()
//                 .registerTypeAdapter(MetaDataVO.class, new MetaDataVOSerializer())
//                 .registerTypeAdapter(TabVO.class, new TabVOSerializer(jsonFilterProvider))
//                 .create();
//     }
// 
//     /**
//      * @return a fully configured {@link Gson} instance
//      */
//     public Gson getGson() {
//         return gson;
//     }
// }
// 
// Path: src/main/java/com/codereligion/bugsnag/logback/resource/NotifierResource.java
// @Path("/")
// @Produces(MediaType.APPLICATION_JSON)
// public interface NotifierResource {
// 
//     @POST
//     @Consumes(MediaType.APPLICATION_JSON)
//     Response sendNotification(NotificationVO notificationVO);
// }


import ch.qos.logback.core.spi.ContextAware;
import com.codereligion.bugsnag.logback.model.NotificationVO;
import com.codereligion.bugsnag.logback.resource.GsonMessageBodyWriter;
import com.codereligion.bugsnag.logback.resource.GsonProvider;
import com.codereligion.bugsnag.logback.resource.NotifierResource;
import com.google.gson.Gson;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.core.Response;
import org.jboss.resteasy.client.jaxrs.ResteasyWebTarget;
/**
 * Copyright 2014 www.codereligion.com
 *
 * 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.codereligion.bugsnag.logback;


/**
 * Sends {@link NotificationVO}s to the bugsnag endpoint.
 *
 * @author Sebastian Gröbler
 */
public class Sender {

    /**
     * All known and expected status codes of the bugsnag endpoint.
     */
    public static final class StatusCode {
        public static final int OK = 200;
        public static final int BAD_REQUEST = 400;
        public static final int UNAUTHORIZED = 401;
        public static final int REQUEST_ENTITY_TOO_LARGE = 413;
        public static final int TOO_MANY_REQUESTS = 429;
    }

    private String endpoint;
    private ContextAware contextAware;
// Path: src/main/java/com/codereligion/bugsnag/logback/model/NotificationVO.java
// public class NotificationVO {
// 
//     /**
//      * The api key associated with the project. Informs bugsnag which project has generated this error.
//      */
//     private String apiKey;
// 
//     /**
//      * This object describes the notifier itself. These properties are used
//      * within bugsnag to track error rates from a notifier.
//      */
//     private NotifierVO notifier = new NotifierVO();
// 
//     /**
//      * A list of error events that bugsnag should be notified of. In the current version of his notifier
//      * the list will contain only one event.
//      */
//     private List<EventVO> events = Lists.newArrayList();
// 
//     public String getApiKey() {
//         return apiKey;
//     }
// 
//     public void setApiKey(final String apiKey) {
//         this.apiKey = apiKey;
//     }
// 
//     public List<EventVO> getEvents() {
//         return events;
//     }
// 
//     public void addEvents(final List<EventVO> events) {
//         this.events.addAll(events);
//     }
// 
//     public NotifierVO getNotifier() {
//         return notifier;
//     }
// }
// 
// Path: src/main/java/com/codereligion/bugsnag/logback/resource/GsonMessageBodyWriter.java
// @Provider
// @Produces(MediaType.APPLICATION_JSON)
// public class GsonMessageBodyWriter implements MessageBodyWriter<Object> {
// 
//     private final Gson gson;
// 
//     /**
//      * Creates a new instance using the given {@code gson} for serialization.
//      * @param gson the {@link Gson} object to use
//      */
//     public GsonMessageBodyWriter(final Gson gson) {
//         this.gson = gson;
//     }
// 
//     @Override
//     public boolean isWriteable(
//             final Class<?> type,
//             final Type genericType,
//             final Annotation[] annotations,
//             final MediaType mediaType) {
//         return true;
//     }
// 
//     @Override
//     public long getSize(
//             final Object object,
//             final Class<?> type,
//             final Type genericType,
//             final Annotation[] annotations,
//             final MediaType mediaType) {
//         return -1;
//     }
// 
//     @Override
//     public void writeTo(
//             final Object object,
//             final Class<?> type,
//             final Type genericType,
//             final Annotation[] annotations,
//             final MediaType mediaType,
//             final MultivaluedMap<String, Object> httpHeaders,
//             final OutputStream entityStream) throws IOException {
// 
//         final OutputStreamWriter writer = new OutputStreamWriter(entityStream, Charsets.UTF_8);
// 
//         try {
//             gson.toJson(object, type, writer);
//         } finally {
//             writer.close();
//         }
//     }
// }
// 
// Path: src/main/java/com/codereligion/bugsnag/logback/resource/GsonProvider.java
// public class GsonProvider {
// 
//     private final Gson gson;
// 
//     /**
//      * Creates a new instance with the given {@code jsonFilterProvider}.
//      *
//      * @param jsonFilterProvider the {@link JsonFilterProvider} implementation to use
//      */
//     public GsonProvider(final JsonFilterProvider jsonFilterProvider) {
//         this.gson = new GsonBuilder()
//                 .registerTypeAdapter(MetaDataVO.class, new MetaDataVOSerializer())
//                 .registerTypeAdapter(TabVO.class, new TabVOSerializer(jsonFilterProvider))
//                 .create();
//     }
// 
//     /**
//      * @return a fully configured {@link Gson} instance
//      */
//     public Gson getGson() {
//         return gson;
//     }
// }
// 
// Path: src/main/java/com/codereligion/bugsnag/logback/resource/NotifierResource.java
// @Path("/")
// @Produces(MediaType.APPLICATION_JSON)
// public interface NotifierResource {
// 
//     @POST
//     @Consumes(MediaType.APPLICATION_JSON)
//     Response sendNotification(NotificationVO notificationVO);
// }


// Path: src/main/java/com/codereligion/bugsnag/logback/Sender.java
import ch.qos.logback.core.spi.ContextAware;
import com.codereligion.bugsnag.logback.model.NotificationVO;
import com.codereligion.bugsnag.logback.resource.GsonMessageBodyWriter;
import com.codereligion.bugsnag.logback.resource.GsonProvider;
import com.codereligion.bugsnag.logback.resource.NotifierResource;
import com.google.gson.Gson;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.core.Response;
import org.jboss.resteasy.client.jaxrs.ResteasyWebTarget;

/**
 * Copyright 2014 www.codereligion.com
 *
 * 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.codereligion.bugsnag.logback;


/**
 * Sends {@link NotificationVO}s to the bugsnag endpoint.
 *
 * @author Sebastian Gröbler
 */
public class Sender {

    /**
     * All known and expected status codes of the bugsnag endpoint.
     */
    public static final class StatusCode {
        public static final int OK = 200;
        public static final int BAD_REQUEST = 400;
        public static final int UNAUTHORIZED = 401;
        public static final int REQUEST_ENTITY_TOO_LARGE = 413;
        public static final int TOO_MANY_REQUESTS = 429;
    }

    private String endpoint;
    private ContextAware contextAware;
    private GsonProvider gsonProvider;