package com.paulvarry.intra42.api.model;

import androidx.annotation.Nullable;
import com.google.gson.annotations.SerializedName;
import com.paulvarry.intra42.api.ApiService;
import com.paulvarry.intra42.utils.Pagination;
import retrofit2.Response;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

public class Campus {

    private static final String API_ID = "id";
    private static final String API_NAME = "name";
    private static final String API_TIME_ZONE = "time_zone";
    private static final String API_LANGUAGE = "language";
    private static final String API_USERS_COUNT = "users_count";

    @SerializedName(API_ID)
    public int id;
    @SerializedName(API_NAME)
    public String name;
    @SerializedName(API_TIME_ZONE)
    public String timeZone;
    @SerializedName(API_USERS_COUNT)
    public int userCount;
    @SerializedName(API_LANGUAGE)
    public Language language;

    public static List<String> getStrings(List<Campus> campusList) {
        List<String> l = new ArrayList<>();

        for (Campus c : campusList) {
            l.add(c.name);
        }

        return l;
    }

    @Nullable
    public static List<Campus> getCampus(ApiService api) {
        List<Campus> list = new ArrayList<>();
        int i = 0;
        int pageSize = 30;

        try {
            while (i < 10 && Pagination.canAdd(list, pageSize)) {
                Response<List<Campus>> response = api.getCampus(pageSize, Pagination.getPage(list, pageSize)).execute();
                List<Campus> tmp = response.body();
                if (!response.isSuccessful())
                    break;
                list.addAll(tmp);
                ++i;
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
        if (list.isEmpty())
            return null;
        return list;
    }

}

@@ -39,45 +39,8 @@
 l;%0A%0A
-import androidx.annotation.Nullable;%0A
 impo
@@ -181,35 +181,8 @@
 ion;
-%0Aimport retrofit2.Response;
 %0A%0Aim
@@ -259,16 +259,81 @@
 .List;%0A%0A
+import androidx.annotation.Nullable;%0Aimport retrofit2.Response;%0A%0A
 public c
@@ -634,298 +634,1226 @@
 t%22;%0A
-%0A    @SerializedName(API_ID)%0A    public int id;%0A    @SerializedName(API_NAME)%0A    public String name;%0A    @SerializedName(API_TIME_ZONE)%0A    public String timeZone;%0A    @SerializedName(API_USERS_COUNT)%0A    public int userCount;%0A    @SerializedName(API_LANGUAGE)%0A    public Language language
+    private static final String API_VOGSPHERE_ID = %22vogsphere_id%22;%0A    private static final String API_COUNTRY = %22country%22;%0A    private static final String API_ADDRESS = %22address%22;%0A    private static final String API_ZIP = %22zip%22;%0A    private static final String API_CITY = %22city%22;%0A    private static final String API_WEBSITE = %22website%22;%0A    private static final String API_FACEBOOK = %22facebook%22;%0A    private static final String API_TWITTER = %22twitter%22;%0A%0A    @SerializedName(API_ID)%0A    public int id;%0A    @SerializedName(API_NAME)%0A    public String name;%0A    @SerializedName(API_TIME_ZONE)%0A    public String timeZone;%0A    @SerializedName(API_USERS_COUNT)%0A    public int userCount;%0A    @SerializedName(API_LANGUAGE)%0A    public Language language;%0A    @SerializedName(API_VOGSPHERE_ID)%0A    public int vogsphereId;%0A    @SerializedName(API_COUNTRY)%0A    public String country;%0A    @SerializedName(API_ADDRESS)%0A    public String address;%0A    @SerializedName(API_ZIP)%0A    public String zip;%0A    @SerializedName(API_CITY)%0A    public String city;%0A    @SerializedName(API_WEBSITE)%0A    public String website;%0A    @SerializedName(API_FACEBOOK)%0A    public String facebook;%0A    @SerializedName(API_TWITTER)%0A    public String twitter
 ;%0A%0A 

update Campus model