Subscription API.

 

The subscription API provides access to subscription methods from other systems.

The url for the APi is located at http://client.url/api/subscriptionapi.asmx

The service description is located at http://client.url/api/subscriptionapi.asmx?WSDL

All methods raise a soap exception if an error occurs. These will need to be handled by the client.

Methods

Method : SubscribeUser

This method subscribes a new user to your publication. Its uses the data contained in the sub & user classes to subscribe the user.

Parameter

Type

Description

PID

Guid

This is a unique key for each publication that allows access to the subscription API. This will be supplied by Realview.

sub

user_subscripiton_info

The class contains the subscription data for this method. See the class definition below for a detailed view of this class.

user

user_info

This class contains the user data for this method. See the class definition below for a detailed view of this class.

 

Return Value. A user_info class is returned. The user_info.guid value can used to identify the created user.

 

Method : SubscribeExistingUser

This method subscribes an existing user to your publication. It uses an existing unique user identifier the data contained in the sub & user classes to subscribe the user.

Parameter

Type

Description

PID

Guid

This is a unique key for each publication that allows access to the subscription API. This will be supplied by Realview.

sub

user_subscripiton_info

The class contains the subscription data for this method. See the class definition below for a detailed view of this class.

UID

Guid

This uniquely identifies the user in the Realview system. Use the GetUser() method to find this value.

 

Return Value. None.

 

Method: IsSubscriberActive

This method checks if a user has a valid subscription.

Parameter

Type

Description

PID

Guid

This is a unique key for each publication that allows access to the subscription API. This will be supplied by Realview.

emailaddress

String

This is the email address of the subscriber you want to check.

 

Return Value: A boolean value is returned that identifies if a user has an active subscription or not.

 

Method: UpdateUser

This method updates the users details.

Parameter

Type

Description

PID

Guid

This is a unique key for each publication that allows access to the subscription API. This will be supplied by Realview.

user

user_info

This contains the updated values for the user.

 

Return Value: true if the update was successful.

 


 

Method: GetUser

This method retrieves a user.

Parameter

Type

Description

PID

Guid

This is a unique key for each publication that allows access to the subscription API. This will be supplied by Realview.

emailaddress

String

This is the email address of the subscriber you want to get.

 

Return Value: returns a user_info class with the requested users details.

Method: UserExists

This method checks if a user exists.

Parameter

Type

Description

PID

Guid

This is a unique key for each publication that allows access to the subscription API. This will be supplied by Realview.

emailaddress

String

This is the email address of the subscriber you want to get.

 

Return Value: true if the user exists otherwise false.

 

Method: GetSubscriptionsForSubscriber

This method retrieves all the subscriptions a user is subscribed to.

Parameter

Type

Description

PID

Guid

This is a unique key for each publication that allows access to the subscription API. This will be supplied by Realview.

User_guid

Guid

This is the guid for the user. If it retrieved using the GetUser() method.

 

Return Value: returns an array of user_subscription_info class with the requested subscription details. The array is order by subscription start date.


 

 

Method: GetSubscriptions

This method gets all subscriptions created for the publication specified.

Parameter

Type

Description

PID

Guid

This is a unique key for each publication that allows access to the subscription API. This will be supplied by Realview.

 

Return Value: returns an array of subscription_info.

Method: GetWelcomeEmails

This method gets all Welcome Emails created for the publication.

Parameter

Type

Description

PID

Guid

This is a unique key for each publication that allows access to the subscription API. This will be supplied by Realview.

 

Return Value: returns an array of email_info


 

Method: GetSubscribers

This method gets all subscribers for the publication specified.

Parameter

Type

Description

PID

Guid

This is a unique key for each publication that allows access to the subscription API. This will be supplied by Realview.

Type

Int

What set of subscribers to return.

Type=1 : All subscribers for the publication.

Type=2 : All subscribers with a subscription created between start and end dates.

StartDate

Datetime

The start date used for subscription creation when requesting a subset of users.

EndDate

DateTime

The end date used for subscription creation when requesting a subset of users.

 

Return Value: returns an array of User.

 

 

Method: GetIssues

This method returns a list of all the live issues for the given publication.

Parameter

Type

Description

PID

Guid

This is a unique key for each publication that allows access to the subscription API. This will be supplied by Realview.

 

Returns an array of issues ordered by issue date.

 

Method : SubscribeUserToIssue

This method subscribes a new user to your publication. Its uses the data contained in the sub & user classes and the IssueID to subscribe the user.

Parameter

Type

Description

PID

Guid

This is a unique key for each publication that allows access to the subscription API. This will be supplied by Realview.

sub

user_subscripiton_info

The class contains the subscription data for this method. See the class definition below for a detailed view of this class.

user

user_info

This class contains the user data for this method. See the class definition below for a detailed view of this class.

IssueID

Int

The issue you want to subscribe the user to.

 

The SubscripotionID in the sub class must be a subscription of fixed type to use this method.

You do not need to set the Start and End dates in the subscription class as these are calculated from the Issue.

Return Value. A user_info class is returned. The user_info.guid value can used to identify the created user.


 

Method : SubscribeExistingUserToIssue

This method subscribes a new user to your publication. Its uses the data contained in the sub & user classes and the IssueID to subscribe the user.

Parameter

Type

Description

PID

Guid

This is a unique key for each publication that allows access to the subscription API. This will be supplied by Realview.

sub

user_subscripiton_info

The class contains the subscription data for this method. See the class definition below for a detailed view of this class.

UID

Guid

This uniquely identifies the user in the Realview system. Use the GetUser() method to find this value.

IssueID

Int

The issue you want to subscribe the user to.

 

The SubscripotionID in the sub class must be a subscription of fixed type to use this method.

You do not need to set the Start and End dates in the subscription class as these are calculated from the Issue.

Return Value. None.


 

 

Classes

 

Class: subscription_info

This contains properties of the subscription for this publication. You can create or modify existing subscription using PAC.

Property

Type

Description

Name

String

This is the name of the subscription.

Description

String

This is a description of the description.

ID

Int

The ID of the subscription. Use this value when subscribing to subscribe the user to this subscription.

 

 

Class: email_info

This contains properties of the email for this publication. You can create or modify existing emails using PAC.

Property

Type

Description

Name

String

This is the name of the email

Subject

String

This is the subject of the email.

ID

Int

This is the unique value that identifies the email. Use this when subscribing if you want to send the user an email.

 

 

 

Class: user_subscription_info

Property

Type

Description

ID

Int

This is the ID of the subscription you want to subscribe the subscriber to.

StartDate

DateTime

This is the date you want the subscription to start on.

EndDate

DateTime

This the date you want the subscription to end on. This is only applicable with a subscription of type Fixed. It will be ignored of the subscription is of any other type.

SubscriptionStartOption

Int

This tells the system what date to start the subscription.

Possible Values:

1 : Use the StartDate supplied in this class.

2 : Use the publish date of the current issue of the publication. This ensures that the user will have access to the current issue in the viewer.

SendWelcomeEmail

Bool

The system will send a welcome email to the user if this value is true otherwise it will not. You must specify an WelcomeEmailID if this value is true.

WelcomeEmailID

Int

This is the ID of the email you want to send once subscription has been processed.

 

 

 

Class: user_info

This class contains the details of the user.

Property

Type

Description

emailaddress

string

The email address of the user.

login

string

The login name of the user.

password

String

The password of the user.

first_name

String

The first name of the user.

last_name

String

The last name of the user.

user_guid

Guid

The unique identifier that is used to identify the user.

status

Int

The status of the user.

message

String

Not used.

Notify

Boolean

This flag tells the email system whether or not this user has chosen to receive emails.

Active

Boolean

This flag tells the system if this user is active or not.

 

Class: issue

This class contains details of the live issues in your publication.

Property

Type

Description

name

String

The name of the issue.

thumb

String

A url for the thumbnail for this issue.

issuedate

DateTime

The issuedate of the issue.

id

Int

The ID of the issue.

link

String

A direct url to the issue.

 


 

Example

 

This example uses the VS2008 “Add Web Reference” to generate C# proxy classes for the webservice. wsdl2perl, wsdl2java should produce similar proxy classes for Perl and Java.

Subscribing a user

 

The first step in using the subscription API is to create some subscriptions in PAC.

You can create date or issue based subscriptions in PAC. Contact Realview if you need help setting these up.

To get the subscription ID to pass to the SubscribeUser method you need to make a call to the GetSubscriptions method.

If you want to send an email after the subscription has completed then you will need to create an email in PAC. You can use the GetEmails method to get the email ID you would like to send.

 

realview.subscription.subscriptionapi subapi = new webservice_test.realview.subscription.subscriptionapi();

 

// create the user_info class and assign the properties

realview.subscription.user_info user = new webservice_test.realview.subscription.user_info();

 

user.emailaddress = "[email protected]";

user.login = user.emailaddress;

user.password = "qwerty789";

user.first_name = "fergus";

user.last_name = "rourke";

user.status = 1;

 

// create the subscription_info class and assign properties

realview.subscription.user_subscription_info sub_info = new webservice_test.realview.subscription.user_subscription_info();

sub_info.StartDate = DateTime.Now.Date;

sub_info.SubscriptionStartOption = 2; // Start date will be publish date of currect issue.

sub_info.SendWelcomeEmail = true;

sub_info.WelcomeEmailID = 30; // ID retrieved from GetEmails()

sub_info.ID = 751; // ID retrieved from GetSubscriptions()

 

// Call the webservice to do the work

user = subapi.SubscribeUser(PID, sub_info, user);

 

// Do something with the returned user information.

do_something (user); 

 

Adding a subscription to an existing user.

To add a subscription to an existing subscriber you firstly need to see if that user exists in the Realview system. Call the GetUser() method to check if the user exists. Using the returned unique user identifier (user_guid) you then call SubscribeExistingUser() to add the subscription. If the user does not exist then you can subscribe the user using SubscribeUser().

This example user C# and Visual Studion 2008 with a Web Reference to the WSDL.

 

string email = "[email protected]";

 

realview.subscription.user_subscription_info sub = new realview.subscription.user_subscription_info();

sub.ID = 751;// 1836;

sub.StartDate = DateTime.Now.Date;

sub.SubscriptionStartOption = 1;

sub.SendWelcomeEmail = false;

 

//Guid PID = new Guid("A9891635-C672-48D2-9809-F636538DF02F");

Guid PID = new Guid("93AD2943-072F-4513-874A-221C5F12DD17");

realview.subscription.subscriptionapi api = new realview.subscription.subscriptionapi();

 

try

{

// find the user.

realview.subscription.user_info user = api.GetUser(PID, email); // throws error if the email is not found.

 

// add the subscription to the user we found.

api.SubscribeExistingUser(PID, user.user_guid, sub);

}

catch

{

// user was not found - create the user & subscribe them.

realview.subscription.user_info user = new realview.subscription.user_info();

user.Active = true;

user.emailaddress = "[email protected]";

user.first_name = "test";

user.last_name = "api";

user.login = "fergus";

user.Notify = false;

user.status = 1;

user.password = "mypwd";

user.user_guid = Guid.NewGuid();

 

// creatw the user & subscribe

api.SubscribeUser(PID, sub, user);

}