// Path: app/src/main/java/de/mygrades/main/events/ErrorEvent.java
// public class ErrorEvent {
//     private ErrorType type;
//     private String msg;
// 
//     public ErrorEvent() {
//     }
// 
//     public ErrorEvent(ErrorType type, String msg) {
//         this.type = type;
//         this.msg = msg;
//     }
// 
//     public ErrorType getType() {
//         return type;
//     }
// 
//     public void setType(ErrorType type) {
//         this.type = type;
//     }
// 
//     public String getMsg() {
//         return msg;
//     }
// 
//     public void setMsg(String msg) {
//         this.msg = msg;
//     }
// 
//     public enum ErrorType {
//         GENERAL, TIMEOUT, NO_NETWORK
//     }
// }
// 
// Path: app/src/main/java/de/mygrades/main/events/PostWishDoneEvent.java
// public class PostWishDoneEvent {
// }


import android.content.Context;
import de.greenrobot.event.EventBus;
import de.mygrades.BuildConfig;
import de.mygrades.main.events.ErrorEvent;
import de.mygrades.main.events.PostWishDoneEvent;
import retrofit.RetrofitError;
package de.mygrades.main.processor;



/**
 * WishProcessor is used to send university wishes from users to the server.
 */
public class WishProcessor extends BaseProcessor {
    private static final String TAG = WishProcessor.class.getSimpleName();

    public WishProcessor(Context context) {
        super(context);
    }

    /**
     * Posts an university wish to the server.
     *
     * @param universityName - university name
     * @param name - name
     * @param email - email address
     * @param message - message
     */
    public void postWish(String universityName, String name, String email, String message) {
        // No Connection -> event no Connection, abort
        if (!isOnline()) {
            postErrorEvent(ErrorEvent.ErrorType.NO_NETWORK, "No Internet Connection!");
            return;
        }

        try {
            // create wish
            Wish wish = new Wish();
            wish.setUniversityName(universityName);
            wish.setName(name);
            wish.setEmail(email);
            wish.setMessage(message);
            wish.setAppVersion(BuildConfig.VERSION_NAME);

            // post to server
            restClient.getRestApi().postWish(wish);

            // post event
// Path: app/src/main/java/de/mygrades/main/events/ErrorEvent.java
// public class ErrorEvent {
//     private ErrorType type;
//     private String msg;
// 
//     public ErrorEvent() {
//     }
// 
//     public ErrorEvent(ErrorType type, String msg) {
//         this.type = type;
//         this.msg = msg;
//     }
// 
//     public ErrorType getType() {
//         return type;
//     }
// 
//     public void setType(ErrorType type) {
//         this.type = type;
//     }
// 
//     public String getMsg() {
//         return msg;
//     }
// 
//     public void setMsg(String msg) {
//         this.msg = msg;
//     }
// 
//     public enum ErrorType {
//         GENERAL, TIMEOUT, NO_NETWORK
//     }
// }
// 
// Path: app/src/main/java/de/mygrades/main/events/PostWishDoneEvent.java
// public class PostWishDoneEvent {
// }


// Path: app/src/main/java/de/mygrades/main/processor/WishProcessor.java
import android.content.Context;
import de.greenrobot.event.EventBus;
import de.mygrades.BuildConfig;
import de.mygrades.main.events.ErrorEvent;
import de.mygrades.main.events.PostWishDoneEvent;
import retrofit.RetrofitError;

package de.mygrades.main.processor;



/**
 * WishProcessor is used to send university wishes from users to the server.
 */
public class WishProcessor extends BaseProcessor {
    private static final String TAG = WishProcessor.class.getSimpleName();

    public WishProcessor(Context context) {
        super(context);
    }

    /**
     * Posts an university wish to the server.
     *
     * @param universityName - university name
     * @param name - name
     * @param email - email address
     * @param message - message
     */
    public void postWish(String universityName, String name, String email, String message) {
        // No Connection -> event no Connection, abort
        if (!isOnline()) {
            postErrorEvent(ErrorEvent.ErrorType.NO_NETWORK, "No Internet Connection!");
            return;
        }

        try {
            // create wish
            Wish wish = new Wish();
            wish.setUniversityName(universityName);
            wish.setName(name);
            wish.setEmail(email);
            wish.setMessage(message);
            wish.setAppVersion(BuildConfig.VERSION_NAME);

            // post to server
            restClient.getRestApi().postWish(wish);

            // post event
            EventBus.getDefault().post(new PostWishDoneEvent());