cancel
Showing results for 
Search instead for 
Did you mean: 
cancel

Now Available: Context Service SDK version 2.0.5

316
Views
11
Helpful
0
Comments
Beginner

Hello,

We are excited to announce that the 2.0.5 version of the Context Service SDK is now available. This version of the Context Service SDK features an updated object model. You can download the 2.0.5 version of the Context Service SDK from the Context Service Downloads page on DevNet. Context Service has also updated the sample code available in the Context Service Sample Code GitHub repository to include changes for the 2.0.5 SDK version.

Context Service Object Changes

In previous versions of the SDK, Context Service managed objects using the Customer, Request, and Pod (activity) classes. These classes still work, but they are deprecated in the 2.0.5 version of the SDK.


Context Service now manages objects using different types of the generic object ContextObject. For example, ContextObject.Types.CUSTOMER.


The valid ContextObject type values are:

  • ContextObject.Types.CUSTOMER
  • ContextObject.Types.REQUEST
  • ContextObject.Types.POD (activity)
  • ContextObject.Types.DETAIL


The detail type is new to the Context Service SDK. You can use the detail type to store additional information about another ContextObject. The detail type can also use the subtypes detail.comment and detail.feedback.


Context Service Object Associations

Context Service now requires that you correctly associate the different ContextObject types together. This helps ensure that you map the customer journey and that context information is connected.


Use the setParentId() method on an object to associate the object with a parent object. 

Use the setCustomerId() method on an object to associate the object with a customer.


  • Request—You must associate each request with a customer. Each request requires a customer because requests represent an issue from the perspective of the customer.
  • Detail—You must associate each detail with either a parent activity or a parent request. Each Detail requires a parent object because details contain additional information about another object.
  • Activity—You can optionally associate each activity with a customer and a parent request.
  • Customer—You cannot associate customers with a parent object or another customer.

ContextObjectAssociations.png

In previous versions of the SDK, creating an activity that is associated with a customer and a request looked like this:

public static Pod createPodWithCustomerAndRequest(ContextServiceClient contextServiceClient, Customer customer, Request request) {

    Pod pod = new Pod(

            DataElementUtils.convertDataMapToSet(

                    new HashMap<String, Object>() {{

                        put("Context_Notes", "Notes about this context.");

                        put("Context_POD_Activity_Link", "http://myservice.example.com/service/ID/xxxx");

                    }}

            )

    );

    pod.setFieldsets(Arrays.asList("cisco.base.pod"));

    pod.setCustomerId(customer.getId());

    pod.setRequestId(request.getId());

    contextServiceClient.create(pod);

    return pod;

}


In the 2.0.5 version of the SDK, creating an activity that is associated with a customer and a request looks like this:

public static ContextObject createPodWithCustomerAndRequest(ContextServiceClient contextServiceClient, ContextObject customer, ContextObject request) {

    ContextObject pod = new ContextObject(ContextObject.Types.POD);

    pod.setDataElements(

            DataElementUtils.convertDataMapToSet(

                    new HashMap<String, Object>() {{

                        put("Context_Notes", "Notes about this context.");

                        put("Context_POD_Activity_Link", "http://myservice.example.com/service/ID/xxxx");

                    }}

            )

    );

    pod.setFieldsets(Arrays.asList("cisco.base.pod"));

    pod.setCustomerId(customer.getId());

    pod.setParentId(request.getId());

    contextServiceClient.create(pod);

    return pod;

}

In the 2.0.5 version of the SDK, you use the different ContextObject types instead of the Customer, Request, or Activity classes. Instead of using the setRequestId() method to associate an activity with a request, you use the setParentId() method to associate an activity with a request.


Getting an Object

When getting a ContextObject in the 2.0.5 version of the SDK, use the ContextServiceClient getContextObject() method and pass in the object type.


Old way:

public static Request getRequest(ContextServiceClient contextServiceClient, UUID requestId) {

    return contextServiceClient.get(Request.class, requestId.toString());

}


New way:

public static ContextObject getRequest(ContextServiceClient contextServiceClient, UUID requestId) {

    return contextServiceClient.getContextObject(ContextObject.Types.REQUEST, requestId.toString());

}


Context Service Object State

In previous versions of the SDK, Context Service used the PodState class to specify if an activity was active or closed. PodState is deprecated in the 2.0.5 version of the SDK.


Context Service now uses the ContextObject.States class to control the object state.


  • Requests can be either active or closed. You can update requests if they are in the active state.
  • Details are always closed. You cannot update details.
  • Customers are always active and cannot be set to closed. You can always update customers.


Note: Though activities can be either active or closed, you can update activities regardless of the object state.

You can find more examples that demonstrate how to use the updated Context Service object model in the Context Service SDK Guide.


Please let us know if you have any questions about the new version of the SDK!


- Context Service Development Team

CreatePlease to create content
Content for Community-Ad
July's Community Spotlight Awards
This widget could not be displayed.