package com.restbucks.ordering.activities;

import com.restbucks.ordering.domain.Identifier;
import com.restbucks.ordering.domain.Order;
import com.restbucks.ordering.domain.OrderStatus;
import com.restbucks.ordering.repositories.OrderRepository;
import com.restbucks.ordering.representations.OrderRepresentation;

public class PokeActivity {
    public OrderRepresentation makeOldestReady() {
		String firstId = OrderRepository.current().getFirstNonReadyId();
		if (firstId == null) {
			// System.out.println("PokeResource: found no orders, so failing");
			throw new NoOrderMatchesException();
		}
		Order o = OrderRepository.current().get(new Identifier(firstId));
		o.setStatus(OrderStatus.READY); 
		// System.out.println("in PokeResource.poke: made order ready, id = "+firstId);
		OrderRepresentation responseRepresentation = new OrderRepresentation(o, firstId);
		return responseRepresentation;
    }

}
