aboutsummaryrefslogtreecommitdiff
path: root/WordPress/src/main/java/org/wordpress/android/ui/stats/models/PublicizeModel.java
blob: 295a280613ae85b686083e75846fc0cf0a4148ee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package org.wordpress.android.ui.stats.models;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;

public class PublicizeModel extends BaseStatsModel {
    private String mBlogID;
    private List<SingleItemModel> mServices;

    public PublicizeModel(String blogID, JSONObject response) throws JSONException {
        this.mBlogID = blogID;
        JSONArray services = response.getJSONArray("services");
        if (services.length() > 0) {
            mServices = new ArrayList<>(services.length());
            for (int i = 0; i < services.length(); i++) {
                JSONObject current = services.getJSONObject(i);
                String serviceName = current.getString("service");
                int followers = current.getInt("followers");
                SingleItemModel currentItem = new SingleItemModel(blogID, null, null, serviceName, followers, null, null);
                mServices.add(currentItem);
            }
        }
    }

    public List<SingleItemModel> getServices() {
        return mServices;
    }

    public String getBlogId() {
        return mBlogID;
    }

    public void setBlogId(String blogId) {
        this.mBlogID = blogId;
    }
}