All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.contentstack.sdk.AssetsModel Maven / Gradle / Ivy

There is a newer version: 2.0.1
Show newest version
package com.contentstack.sdk;

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

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

/**
 * The type Assets model.
 */
class AssetsModel {

    List objects = new ArrayList<>();

    /**
     * Instantiates a new Assets model.
     *
     * @param response the response
     */
    public AssetsModel(JSONObject response) {
        JSONArray listResponse = response != null && response.has("assets") ? response.optJSONArray("assets") : null;
        if (listResponse != null) {
            listResponse.forEach(model -> {
                JSONObject modelObj = (JSONObject) model;
                AssetModel newModel = new AssetModel(modelObj, true);
                objects.add(newModel);
            });
        }
    }
}