Cisco Cisco Prime Home 6.3 Developer's Guide

Page of 78
Cisco Prime Home – Integration Guide
 
 
OL-28558-01   v5.1
 
54 
DeviceData.scala 
 
package com.clearaccess.example.api 
 
import org.json.JSONObject 
 
class DeviceData(val json: JSONObject) extends JSONHelpers { 
/** 
* @return the underlying json object 
*/ 
def getJSON() = json 
/** 
* @return the device id as a long value 
*/ 
def getDeviceId(): Long = json.optLong("deviceId") 
 
/** 
* sets the oui and serial number of the device 

* @param oui device oui 
* @param sn device serial number 
* @return self, for chaining 
*/ 
def setOuiSn(oui: String, sn: String): DeviceData = { 
json.put("oui", oui).put("sn", sn) 
this 

 
/** 
* associates this device to an existing subscriber referenced by 
* the given subscriber code 

* @param subscriberCode the code of the subscriber who is 
associated with this device 
* @return self, for chaining 
*/ 
def setSubscriberCode(subscriberCode: String): DeviceData = { 
json.put("subscriberCode", subscriberCode) 
  this 

 
/** 
* Marks this device as being replaced with the device referenced  by 
the parameters. 

* @param sn replacement device sn 
* @param oui replacement device oui 
* @code code integrator specific rma code 
*/ 
def setRMA(sn: String, oui: String, code: String): DeviceData = { 
val rmaFor = new JSONObject 
rmaFor 
.put("sn", sn) 
.put("oui", oui) 
.put("code", code) 
json.put("rmaFor", rmaFor) 
this 

 
/** 
* Marks this device as being replaced with the device referenced 
by the parameters. 

* @param sn replacement device sn 
* @param oui replacement device oui