ar.com.fernandospr.wns
Class WnsService

java.lang.Object
  extended by ar.com.fernandospr.wns.WnsService

public class WnsService
extends Object


Constructor Summary
WnsService(String sid, String clientSecret)
           
WnsService(String sid, String clientSecret, boolean logging)
           
 
Method Summary
protected  void addOptionalHeaders(com.sun.jersey.api.client.WebResource.Builder webResourceBuilder, WnsNotificationRequestOptional optional)
           
protected  void addRequiredHeaders(com.sun.jersey.api.client.WebResource.Builder webResourceBuilder, String type, String accessToken)
           
protected  WnsOAuthToken getAccessToken()
          Based on http://msdn.microsoft.com/en-us/library/windows/apps/hh465407.aspx
protected  WnsNotificationResponse push(String channelUri, String type, WnsAbstractNotification notification, int retriesLeft, WnsNotificationRequestOptional optional)
           
 WnsNotificationResponse pushBadge(String channelUri, WnsBadge badge)
          Pushes a badge to channelUri
 WnsNotificationResponse pushBadge(String channelUri, WnsNotificationRequestOptional optional, WnsBadge badge)
          Pushes a badge to channelUri using optional headers
 WnsNotificationResponse pushTile(String channelUri, WnsNotificationRequestOptional optional, WnsTile tile)
          Pushes a tile to channelUri using optional headers
 WnsNotificationResponse pushTile(String channelUri, WnsTile tile)
          Pushes a tile to channelUri
 WnsNotificationResponse pushToast(String channelUri, WnsNotificationRequestOptional optional, WnsToast toast)
          Pushes a toast to channelUri using optional headers
 WnsNotificationResponse pushToast(String channelUri, WnsToast toast)
          Pushes a toast to channelUri
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WnsService

public WnsService(String sid,
                  String clientSecret)
           throws WnsException
Parameters:
sid -
clientSecret -
Throws:
WnsException - when authentication fails

WnsService

public WnsService(String sid,
                  String clientSecret,
                  boolean logging)
           throws WnsException
Parameters:
sid -
clientSecret -
logging - true if System.out logging is needed
Throws:
WnsException - when authentication fails
Method Detail

getAccessToken

protected WnsOAuthToken getAccessToken()
                                throws WnsException
Based on http://msdn.microsoft.com/en-us/library/windows/apps/hh465407.aspx

Throws:
WnsException - when authentication fails

pushTile

public WnsNotificationResponse pushTile(String channelUri,
                                        WnsTile tile)
                                 throws WnsException
Pushes a tile to channelUri

Parameters:
channelUri -
tile - which should be built with WnsTileBuilder
Returns:
WnsNotificationResponse please see response headers from http://msdn.microsoft.com/en-us/library/windows/apps/hh465435.aspx#send_notification_response
Throws:
WnsException - if it was unable to push the notification, please see response codes from http://msdn.microsoft.com/en-us/library/windows/apps/hh465435.aspx#send_notification_response

pushTile

public WnsNotificationResponse pushTile(String channelUri,
                                        WnsNotificationRequestOptional optional,
                                        WnsTile tile)
                                 throws WnsException
Pushes a tile to channelUri using optional headers

Parameters:
channelUri -
optional -
tile - which should be built with WnsTileBuilder
Returns:
WnsNotificationResponse please see response headers from http://msdn.microsoft.com/en-us/library/windows/apps/hh465435.aspx#send_notification_response
Throws:
WnsException - if it was unable to push the notification, please see response codes from http://msdn.microsoft.com/en-us/library/windows/apps/hh465435.aspx#send_notification_response

pushToast

public WnsNotificationResponse pushToast(String channelUri,
                                         WnsToast toast)
                                  throws WnsException
Pushes a toast to channelUri

Parameters:
channelUri -
toast - which should be built with WnsToastBuilder
Returns:
WnsNotificationResponse please see response headers from http://msdn.microsoft.com/en-us/library/windows/apps/hh465435.aspx#send_notification_response
Throws:
WnsException - if it was unable to push the notification, please see response codes from http://msdn.microsoft.com/en-us/library/windows/apps/hh465435.aspx#send_notification_response

pushToast

public WnsNotificationResponse pushToast(String channelUri,
                                         WnsNotificationRequestOptional optional,
                                         WnsToast toast)
                                  throws WnsException
Pushes a toast to channelUri using optional headers

Parameters:
channelUri -
optional -
toast - which should be built with WnsToastBuilder
Returns:
WnsNotificationResponse please see response headers from http://msdn.microsoft.com/en-us/library/windows/apps/hh465435.aspx#send_notification_response
Throws:
WnsException - if it was unable to push the notification, please see response codes from http://msdn.microsoft.com/en-us/library/windows/apps/hh465435.aspx#send_notification_response

pushBadge

public WnsNotificationResponse pushBadge(String channelUri,
                                         WnsBadge badge)
                                  throws WnsException
Pushes a badge to channelUri

Parameters:
channelUri -
badge - which should be built with WnsBadgeBuilder
Returns:
WnsNotificationResponse please see response headers from http://msdn.microsoft.com/en-us/library/windows/apps/hh465435.aspx#send_notification_response
Throws:
WnsException - if it was unable to push the notification, please see response codes from http://msdn.microsoft.com/en-us/library/windows/apps/hh465435.aspx#send_notification_response

pushBadge

public WnsNotificationResponse pushBadge(String channelUri,
                                         WnsNotificationRequestOptional optional,
                                         WnsBadge badge)
                                  throws WnsException
Pushes a badge to channelUri using optional headers

Parameters:
channelUri -
optional -
badge - which should be built with WnsBadgeBuilder
Returns:
WnsNotificationResponse please see response headers from http://msdn.microsoft.com/en-us/library/windows/apps/hh465435.aspx#send_notification_response
Throws:
WnsException - if it was unable to push the notification, please see response codes from http://msdn.microsoft.com/en-us/library/windows/apps/hh465435.aspx#send_notification_response

push

protected WnsNotificationResponse push(String channelUri,
                                       String type,
                                       WnsAbstractNotification notification,
                                       int retriesLeft,
                                       WnsNotificationRequestOptional optional)
                                throws WnsException
Parameters:
channelUri -
type - should be any of WnsNotificationType
notification -
retriesLeft - to push the notification if the token expires
Returns:
WnsNotificationResponse please see response headers from http://msdn.microsoft.com/en-us/library/windows/apps/hh465435.aspx#send_notification_response
Throws:
WnsException - if it was unable to push the notification, please see response codes from http://msdn.microsoft.com/en-us/library/windows/apps/hh465435.aspx#send_notification_response

addOptionalHeaders

protected void addOptionalHeaders(com.sun.jersey.api.client.WebResource.Builder webResourceBuilder,
                                  WnsNotificationRequestOptional optional)

addRequiredHeaders

protected void addRequiredHeaders(com.sun.jersey.api.client.WebResource.Builder webResourceBuilder,
                                  String type,
                                  String accessToken)


Copyright © 2013. All Rights Reserved.