Cisco Cisco Prime Home 6.3 Developer's Guide

Page of 78
Cisco Prime Home – Integration Guide
 
 
OL-28558-01   v5.1
 
70 
Data Classes 
com.clearaccess.subscriber.api.Subscriber 
/* 
* Copyright (c) 2010 ClearAccess, Inc. 
* This code is provided AS-IS for illustration purposes. 
*/ 
 
package com.clearaccess.subscriber.api; 
 
import org.json.JSONArray; 
import org.json.JSONException; 
import org.json.JSONObject; 
 
public class Subscriber extends JSONObject { 
/** 
* builds this subscriber from the state in the json object. 
* @param json the json representation of the subscriber 
* @throws JSONException from super-constructor 
*/ 
public Subscriber(final JSONObject json) throws JSONException {super 
(json.toString()); 

 
/** 
* creates a new subscriber in an initial state. 
* @param code the code of the new subscriber 
*/ 
public Subscriber(final String code) { 
try { 
put("code", code); 
put("attributes", new JSONObject()); 
put("credentials", new JSONObject()); 
put("labels", new JSONArray()); 
put("subscriptions", new JSONArray()); 
} catch (JSONException e) { 
throw new RuntimeException(e); 

 
public String getCode() { 
try { 
return getString("code"); 
} catch (JSONException e) { 
throw new RuntimeException(e); 

 
public Address getAddress() { 
final JSONObject attributes = optJSONObject("attributes", new 
JSONObject()); 
final String street = 
attributes.optString("Subscriber.Address.1.Street"); 
final String city = 
attributes.optString("Subscriber.Address.1.City"); 
final String state = 
attributes.optString("Subscriber.Address.1.State"); 
final String postalCode = 
attributes.optString("Subscriber.Address.1.PostalCode"); 
return new Address(street, city, state, postalCode); 

 
public void setAddress(final Address address) { 
try {