Esempio n. 1
0
  /**
   * 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());
    } catch (RetrofitError e) {
      postRetrofitError(TAG, e);
    }
  }