示例#1
0
 /**
  * Get details about a single customer, such as current status and contact information.
  *
  * @param customerId
  * @return
  * @throws BssException
  */
 public JsonEntity getCustomerById(String customerId) throws BssException {
   try {
     String serviceUrl =
         BssUrls.API_RESOURCE_CUSTOMER_CUSTOMERID.format(this, BssUrls.customerId(customerId));
     return getEntity(serviceUrl, null, getJsonFeedHandler());
   } catch (Exception e) {
     throw new BssException(
         e, "Error retrieving customer {0} caused by {1}", customerId, e.getMessage());
   }
 }
示例#2
0
  /**
   * Unregister a customer organization using the internal ID of the customer. When you unregister
   * an organization, all subscribers of that customer are deleted, and all subscriptions are
   * cancelled. The customer must be owned by the organization of the authenticated user.
   *
   * @param customerId
   * @return
   * @throws BssException
   */
  public void unregisterCustomer(String customerId) throws BssException {
    try {
      String serviceUrl =
          BssUrls.API_RESOURCE_CUSTOMER_CUSTOMERID.format(this, BssUrls.customerId(customerId));
      Response response = deleteData(serviceUrl, null, null);

      // expect a 204
      int statusCode = response.getResponse().getStatusLine().getStatusCode();
      if (statusCode != 204) {
        throw new BssException(response, "Error unregistering customer {0}", customerId);
      }
    } catch (Exception e) {
      throw new BssException(
          e, "Error unregistering customer {0} caused by {1}", customerId, e.getMessage());
    }
  }
示例#3
0
  /**
   * Change the status of a single customer from active to suspended. A customer who is suspended
   * cannot use any services.
   *
   * @param customerId
   * @return
   * @throws BssException
   */
  public void suspendCustomer(String customerId) throws BssException {
    try {
      String serviceUrl =
          BssUrls.API_RESOURCE_CUSTOMER_CUSTOMERID.format(this, BssUrls.customerId(customerId));
      Response response =
          createData(serviceUrl, (Map<String, String>) null, SuspendCustomerHeader, (Object) null);

      // expect a 204
      int statusCode = response.getResponse().getStatusLine().getStatusCode();
      if (statusCode != 204) {
        throw new BssException(response, "Error suspending customer {0}", customerId);
      }
    } catch (Exception e) {
      throw new BssException(
          e, "Error suspending customer {0} caused by {1}", customerId, e.getMessage());
    }
  }
示例#4
0
  /**
   * Update the profile of a single customer who is part of the organization of the authenticated
   * user. Editable attributes include organization name, address, location, contact information,
   * job title and more.
   *
   * <p>To create the payload, you must first retrieve the most current customer profile for the
   * customer that you intend to update. To retrieve the most current customer profile, use the GET
   * method Get customer by ID, which returns a JSON payload. Update the payload that you retrieve
   * and use it as the new payload. You can update one or more of the mutable attributes that are
   * described in the table Mutable attributes.
   *
   * <p>Note: Attributes that do not have values might not be in the payload that you retrieve. If
   * the attribute that you want to modify is not in the payload that you retrieve, add the
   * attribute and its value to the payload that you submit. Mutable attributes that are not in the
   * payload that you submit are deleted from the database.
   *
   * @param customerObject
   * @throws BssException
   */
  public void updateCustomerProfile(JsonJavaObject customerObject) throws BssException {
    try {
      String customerId = getCustomerId(customerObject);
      String serviceUrl =
          BssUrls.API_RESOURCE_CUSTOMER_CUSTOMERID.format(this, BssUrls.customerId(customerId));
      Response response = updateData(serviceUrl, null, JsonHeader, customerObject, null);

      // expect a 204
      int statusCode = response.getResponse().getStatusLine().getStatusCode();
      if (statusCode != 204) {
        throw new BssException(response, "Error updating customer profile {0}", customerObject);
      }
    } catch (Exception e) {
      throw new BssException(
          e, "Error updating customer profile {0} caused by {1}", customerObject, e.getMessage());
    }
  }