Commit 98899d23 authored by Sajal Narang's avatar Sajal Narang

Implement Create event API

parent 346eb890
...@@ -17,8 +17,8 @@ public interface RetrofitInterface { ...@@ -17,8 +17,8 @@ public interface RetrofitInterface {
@POST("login/") @POST("login/")
Call<LoginResponse> login(@Body LoginRequest loginRequest); Call<LoginResponse> login(@Body LoginRequest loginRequest);
@POST("/createEvent/") @POST("events")
Call<EventCreateResponse> eventCreate(@Body EventCreateRequest eventCreateRequest); Call<EventCreateResponse> createEvent(@Body EventCreateRequest eventCreateRequest);
@GET("users/{uuid}/followed_bodies_events") @GET("users/{uuid}/followed_bodies_events")
Call<NewsFeedResponse> getNewsFeed(@Path("uuid") String uuid); Call<NewsFeedResponse> getNewsFeed(@Path("uuid") String uuid);
......
...@@ -7,7 +7,7 @@ import retrofit2.converter.gson.GsonConverterFactory; ...@@ -7,7 +7,7 @@ import retrofit2.converter.gson.GsonConverterFactory;
public class ServiceGenerator { public class ServiceGenerator {
//TODO: Change BASE_URL once the server is hosted //TODO: Change BASE_URL once the server is hosted
private static final String BASE_URL = "http://temp-iitb.radialapps.com/api/"; private static final String BASE_URL = "https://temp-iitb.radialapps.com/api/";
private static OkHttpClient.Builder clientBuilder = new OkHttpClient.Builder(); private static OkHttpClient.Builder clientBuilder = new OkHttpClient.Builder();
private static Retrofit.Builder retrofitBuilder = new Retrofit.Builder() private static Retrofit.Builder retrofitBuilder = new Retrofit.Builder()
.baseUrl(BASE_URL) .baseUrl(BASE_URL)
......
...@@ -6,43 +6,37 @@ import android.support.annotation.Nullable; ...@@ -6,43 +6,37 @@ import android.support.annotation.Nullable;
import com.google.gson.annotations.SerializedName; import com.google.gson.annotations.SerializedName;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.util.List;
/**
* Created by mrunz on 15/7/17.
*/
public class EventCreateRequest { public class EventCreateRequest {
@SerializedName("event_name") @SerializedName("name")
private String eventName; private String eventName;
@SerializedName("event_description") @SerializedName("description")
private String eventDescription; private String eventDescription;
@SerializedName("event_timing_from") @SerializedName("image_url")
private Timestamp eventTimingFrom; private String eventImageURL;
@SerializedName("event_timing_to") @SerializedName("start_time")
private Timestamp eventTimingTo; private String eventStartTime;
@SerializedName("event_venue_id") @SerializedName("end_time")
private int eventVenueID; private String eventEndTime;
@SerializedName("event_maplocation_id") @SerializedName("all_day")
private int eventMapLocationId; private boolean allDayEvent;
@SerializedName("event_venue") @SerializedName("venue_names")
private String eventVenue; private List<String> eventVenueNames;
@SerializedName("public_status") @SerializedName("bodies_id")
private int publicStatus; private List<String> eventBodiesID;
public EventCreateRequest(String eventName, String eventDescription, String eventImageURL, String eventStartTime, String eventEndTime, boolean allDayEvent, List<String> eventVenueNames, List<String> eventBodiesID) {
public EventCreateRequest(String eventName, String eventDescription,String eventVenue,Timestamp eventTimingFrom,Timestamp eventTimingTo,int publicStatus,@Nullable int eventVenueID,@Nullable int eventMapLocationId) { this.eventName = eventName;
this.eventName=eventName; this.eventDescription = eventDescription;
this.eventDescription=eventDescription; this.eventImageURL = eventImageURL;
this.eventTimingFrom=eventTimingFrom; this.eventStartTime = eventStartTime;
this.eventTimingTo=eventTimingTo; this.eventEndTime = eventEndTime;
this.eventVenueID=eventVenueID; this.allDayEvent = allDayEvent;
this.eventMapLocationId=eventMapLocationId; this.eventVenueNames = eventVenueNames;
this.eventVenue=eventVenue; this.eventBodiesID = eventBodiesID;
this.publicStatus=publicStatus;
} }
public String getEventName() { public String getEventName() {
return eventName; return eventName;
} }
...@@ -59,53 +53,51 @@ public class EventCreateRequest { ...@@ -59,53 +53,51 @@ public class EventCreateRequest {
this.eventDescription = eventDescription; this.eventDescription = eventDescription;
} }
public Timestamp getEventTimingFrom() { public String getEventImageURL() {
return eventTimingFrom; return eventImageURL;
} }
public void setEventTimingFrom(Timestamp eventTimingFrom) { public void setEventImageURL(String eventImageURL) {
this.eventTimingFrom = eventTimingFrom; this.eventImageURL = eventImageURL;
} }
public Timestamp getEventTimingTo() { public String getEventStartTime() {
return eventTimingTo; return eventStartTime;
} }
public void setEventTimingTo(Timestamp eventTimingTo) { public void setEventStartTime(String eventStartTime) {
this.eventTimingTo = eventTimingTo; this.eventStartTime = eventStartTime;
} }
public int getEventVenueID() { public String getEventEndTime() {
return eventVenueID; return eventEndTime;
} }
public void setEventVenueID(@Nullable int eventVenueID) { public void setEventEndTime(String eventEndTime) {
this.eventVenueID = eventVenueID; this.eventEndTime = eventEndTime;
} }
public int getEventMapLocationId() { public boolean isAllDayEvent() {
return eventMapLocationId; return allDayEvent;
} }
public void setEventMapLocationId(@Nullable int eventMapLocationId) { public void setAllDayEvent(boolean allDayEvent) {
this.eventMapLocationId = eventMapLocationId; this.allDayEvent = allDayEvent;
} }
public String getEventVenue() { public List<String> getEventVenueNames() {
return eventVenue; return eventVenueNames;
} }
public void setEventVenue(String eventVenue) { public void setEventVenueNames(List<String> eventVenueNames) {
this.eventVenue = eventVenue; this.eventVenueNames = eventVenueNames;
} }
public int getPublicStatus() { public List<String> getEventBodiesID() {
return publicStatus; return eventBodiesID;
} }
public void setPublicStatus(int publicStatus) { public void setEventBodiesID(List<String> eventBodiesID) {
this.publicStatus = publicStatus; this.eventBodiesID = eventBodiesID;
} }
} }
...@@ -22,7 +22,9 @@ import android.widget.TimePicker; ...@@ -22,7 +22,9 @@ import android.widget.TimePicker;
import android.widget.Toast; import android.widget.Toast;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.util.Arrays;
import java.util.Calendar; import java.util.Calendar;
import java.util.List;
import butterknife.BindView; import butterknife.BindView;
import butterknife.ButterKnife; import butterknife.ButterKnife;
...@@ -203,6 +205,7 @@ public class AddEventFragment extends Fragment { ...@@ -203,6 +205,7 @@ public class AddEventFragment extends Fragment {
Toast.makeText(getContext(), "Add Event", Toast.LENGTH_SHORT).show(); Toast.makeText(getContext(), "Add Event", Toast.LENGTH_SHORT).show();
//TODO (2) save event //TODO (2) save event
addEvent();
} }
}); });
...@@ -212,9 +215,9 @@ public class AddEventFragment extends Fragment { ...@@ -212,9 +215,9 @@ public class AddEventFragment extends Fragment {
} }
public void addEvent() { public void addEvent() {
EventCreateRequest eventCreateRequest = new EventCreateRequest(eventName.getText().toString(), details.getText().toString(), venue.getText().toString(), timestamp_start, timestamp_end, publicStatus, 0, 0); EventCreateRequest eventCreateRequest = new EventCreateRequest(eventName.getText().toString(), details.getText().toString(), "http://resources.wncc-iitb.org/logo_banner.png", timestamp_start.toString(), timestamp_end.toString(), false, Arrays.asList(new String[]{venue.getText().toString()}), Arrays.asList(new String[]{"bde82d5e-f379-4b8a-ae38-a9f03e4f1c4a"}));
RetrofitInterface retrofitInterface = ServiceGenerator.createService(RetrofitInterface.class); RetrofitInterface retrofitInterface = ServiceGenerator.createService(RetrofitInterface.class);
retrofitInterface.eventCreate(eventCreateRequest).enqueue(new Callback<EventCreateResponse>() { retrofitInterface.createEvent(eventCreateRequest).enqueue(new Callback<EventCreateResponse>() {
@Override @Override
public void onResponse(Call<EventCreateResponse> call, Response<EventCreateResponse> response) { public void onResponse(Call<EventCreateResponse> call, Response<EventCreateResponse> response) {
Toast.makeText(getContext(), "Event Created", Toast.LENGTH_SHORT).show(); Toast.makeText(getContext(), "Event Created", Toast.LENGTH_SHORT).show();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment