Package org.multibit.mbm.client.interfaces.rest.api.representations.hal.customer

Source Code of org.multibit.mbm.client.interfaces.rest.api.representations.hal.customer.CustomerRepresentation

package org.multibit.mbm.client.interfaces.rest.api.representations.hal.customer;

import com.google.common.base.Preconditions;
import com.theoryinpractise.halbuilder.DefaultRepresentationFactory;
import com.theoryinpractise.halbuilder.api.Representation;
import com.theoryinpractise.halbuilder.api.RepresentationFactory;
import org.multibit.mbm.client.domain.model.model.Customer;

/**
* <p>Representation to provide the following to {@link org.multibit.mbm.client.domain.model.model.Customer}:</p>
* <ul>
* <li>Creates {@link Representation} representations</li>
* </ul>
*
* @since 0.0.1
*/
public class CustomerRepresentation {

  public Representation get(Customer customer) {
    Preconditions.checkNotNull(customer, "customer");
    Preconditions.checkNotNull(customer.getId(), "id");

    String basePath = "/customer/" + customer.getId();

    // Create top-level resource
    RepresentationFactory factory = new DefaultRepresentationFactory();
    return factory
      .newRepresentation(basePath)
      .withLink("user", "/user/" + customer.getUser().getId())
      .withLink("cart", "/cart/" + customer.getCart().getId());
  }

}
TOP

Related Classes of org.multibit.mbm.client.interfaces.rest.api.representations.hal.customer.CustomerRepresentation

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.