Package models

Examples of models.Subscriber


    cookies.putAll(response.cookies);
    Request request = newRequest();
        request.cookies.putAll(cookies);
    //Create
    String name = "olympia";
    Subscriber subscriber = new Subscriber();
    subscriber.name = name;
    ContactInformation contact_information = new ContactInformation();
    contact_information.email = "lucas@olympia.com";
    subscriber.contact_information = contact_information;
    response = POST(request,
View Full Code Here


  private static void checkDetail(Subscriber originalSubscriber) {
    Response response = GET("/api/subscribers/" + originalSubscriber.id);
    assertIsOk(response);
    assertContentType("application/json", response);
    assertCharset("utf-8", response);
    Subscriber remoteSubscriber = parseJSON(response.out.toByteArray());
    assertEquals("Debe ser el mismo subscriber", remoteSubscriber.id, originalSubscriber.id);
  }
View Full Code Here

 
  private static Subscriber parseJSON(byte[] content) {
    InputStream is = new ByteArrayInputStream(content);
    Reader reader = new InputStreamReader(is);
    Type dataType = new TypeToken<Subscriber>(){}.getType();
    Subscriber subscriber = gson.fromJson(reader, dataType);
    return subscriber;
  }
View Full Code Here

  }
 
  private void loadResidenceB() {
    String old = NamespaceManager.get();
    try {
      Subscriber subscriber = Subscriber.findByName("B");
      assertTrue(subscriber.name.equals("B"));
      NamespaceManager.set(String.valueOf(subscriber.name));
      SienaFixtures.deleteAllModels();
      SienaFixtures.loadModels("subscriber_B.yml");
      assertTrue("En total tiene que haber 1 residencia ", Residence.count()==1);
View Full Code Here

  }
 
  private void loadResidenceA() {
    String old = NamespaceManager.get();
    try {
      Subscriber subscriber = Subscriber.findByName("A");
      assertTrue(subscriber.name.equals("A"));
      NamespaceManager.set(String.valueOf(subscriber.name));
      SienaFixtures.deleteAllModels();
      SienaFixtures.loadModels("subscriber_A.yml");
      Residence residence = Residence.findByName("egaña");
View Full Code Here

    if(username == null) return null;
    User user = null;
    if(username.contains("@")) {
      String oldNamespace = NamespaceManager.get();
      String subscriberName = username.substring(username.indexOf("@")+1);
      Subscriber subscriber = Subscriber.findByName(subscriberName);
      if(null==subscriber) return null;
      username = username.substring(0, username.indexOf("@"));
      flash.put("residence", subscriber.name);
      flash.put("usernameV", username);
      NamespaceManager.set(subscriber.name);
View Full Code Here

    Type dataType = new TypeToken<Data<Subscriber>>(){}.getType();
    renderJSON(gson().toJson(data, dataType));
  }
 
  public static void get(Long id) {
    final Subscriber subscriber = Subscriber.get(id);
    if(subscriber==null) {
      response.status = StatusCode.NOT_FOUND;
      return;
    }
    renderJSON(gson().toJson(subscriber));
View Full Code Here

    }
    renderJSON(gson().toJson(subscriber));
  }
 
  public static void add(JsonObject body) throws ValidationException {
    Subscriber subscriber = new Gson().fromJson(body, Subscriber.class);
    validation.valid(subscriber);
    if(validation.hasErrors()) {
      throw new ValidationException(validation.errors());
    }
    subscriber.insert();
    response.status = StatusCode.CREATED;
    Map map = new HashMap();
    map.put("id", subscriber.id);
    String url = Router.reverse("api.Subscribers.get", map).url;// GET /clients/1541
    response.setHeader("location", url);
View Full Code Here

    response.setHeader("location", url);
    renderJSON(gson().toJson(subscriber));
  }
 
  public static void edit(Long id,  JsonObject body) {
    Subscriber subscriber = new Gson().fromJson(body, Subscriber.class);
    if(subscriber==null) {
      response.status = StatusCode.NOT_FOUND;
      return;
    }
    subscriber.update();
    response.status = StatusCode.OK;
    Map map = new HashMap();
    map.put("id", subscriber.id);
    String url = Router.reverse("api.Subscribers.get", map).url;// GET /clients/1541
    response.setHeader("location", url);
View Full Code Here

    String url = Router.reverse("api.Subscribers.get", map).url;// GET /clients/1541
    response.setHeader("location", url);
  }
 
  public static void delete(Long id) {
    final Subscriber subscriber = Subscriber.get(id);
    if(subscriber==null) {
      response.status = StatusCode.NOT_FOUND;
      return;
    }
    subscriber.delete();
    response.status = StatusCode.NO_RESPONSE;
  }
View Full Code Here

TOP

Related Classes of models.Subscriber

Copyright © 2018 www.massapicom. 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.