/*
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.aliyuncs.cloudphoto.transform.v20170711;

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

import com.aliyuncs.cloudphoto.model.v20170711.ListMomentPhotosResponse;
import com.aliyuncs.cloudphoto.model.v20170711.ListMomentPhotosResponse.Result;
import com.aliyuncs.transform.UnmarshallerContext;


public class ListMomentPhotosResponseUnmarshaller {

	public static ListMomentPhotosResponse unmarshall(ListMomentPhotosResponse listMomentPhotosResponse, UnmarshallerContext context) {
		
		listMomentPhotosResponse.setRequestId(context.stringValue("ListMomentPhotosResponse.RequestId"));
		listMomentPhotosResponse.setCode(context.stringValue("ListMomentPhotosResponse.Code"));
		listMomentPhotosResponse.setMessage(context.stringValue("ListMomentPhotosResponse.Message"));
		listMomentPhotosResponse.setNextCursor(context.stringValue("ListMomentPhotosResponse.NextCursor"));
		listMomentPhotosResponse.setTotalCount(context.integerValue("ListMomentPhotosResponse.TotalCount"));
		listMomentPhotosResponse.setAction(context.stringValue("ListMomentPhotosResponse.Action"));

		List<Result> results = new ArrayList<Result>();
		for (int i = 0; i < context.lengthValue("ListMomentPhotosResponse.Results.Length"); i++) {
			Result result = new Result();
			result.setPhotoId(context.longValue("ListMomentPhotosResponse.Results["+ i +"].PhotoId"));
			result.setPhotoIdStr(context.stringValue("ListMomentPhotosResponse.Results["+ i +"].PhotoIdStr"));
			result.setState(context.stringValue("ListMomentPhotosResponse.Results["+ i +"].State"));

			results.add(result);
		}
		listMomentPhotosResponse.setResults(results);
	 
	 	return listMomentPhotosResponse;
	}
}