示例#1
0
  /**
   * this method delete a particular Contact in zoho.com and returns success message with deleted
   * Contact id. This method takes input as a MAP(contains json dada) and returns a MAP.
   *
   * @param outMap
   */
  private Map<String, String> delete(Map<String, String> outMap) {

    List<NameValuePair> contactAttrList = new ArrayList<NameValuePair>();
    contactAttrList.add(new BasicNameValuePair(OAUTH_TOKEN, args.get(AUTHTOKEN)));
    contactAttrList.add(new BasicNameValuePair(ZOHO_SCOPE, SCOPE));
    contactAttrList.add(new BasicNameValuePair(ID, args.get(ID)));

    TransportTools tst =
        new TransportTools(ZOHO_CRM_CONTACT_JSON_URL + DELETE_RECORDS, contactAttrList);
    String responseBody = null;

    TransportResponse response = null;

    try {
      response = TransportMachinery.post(tst);
    } catch (ClientProtocolException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    responseBody = response.entityToString();

    outMap.put(OUTPUT, responseBody);
    return outMap;
  }
示例#2
0
  /**
   * this method update a particular Contact in zoho.com and returns success message with updated
   * Contact id. This method takes input as a MAP(contains json dada) and returns a MAP.
   *
   * @param outMap
   */
  private Map<String, String> update(Map<String, String> outMap) {

    Contacts contacts = new Contacts();
    contacts.setLast_Name(args.get(LASTNAME));
    contacts.setEmail(args.get(EMAIL));
    contacts.setLead_Source(args.get(LEAD_SOURCE));
    contacts.setFax(args.get(FAX));
    contacts.setPhone(args.get(PHONE));
    String xmlout = null;
    try {
      xmlout = contacts.toXMLString();
    } catch (JAXBException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    List<NameValuePair> contactAttrList = new ArrayList<NameValuePair>();
    contactAttrList.add(new BasicNameValuePair(OAUTH_TOKEN, args.get(AUTHTOKEN)));
    contactAttrList.add(new BasicNameValuePair(ZOHO_SCOPE, SCOPE));
    contactAttrList.add(new BasicNameValuePair(ID, args.get(ID)));
    contactAttrList.add(new BasicNameValuePair(ZOHO_XMLDATA, xmlout));

    TransportTools tst =
        new TransportTools(ZOHO_CRM_CONTACT_XML_URL + UPDATE_RECORDS, contactAttrList);
    String responseBody = null;

    TransportResponse response = null;

    try {
      response = TransportMachinery.post(tst);
    } catch (ClientProtocolException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    responseBody = response.entityToString();

    outMap.put(OUTPUT, responseBody);
    return outMap;
  }