Logo

Docs

  • HOME

Source: User/UserSupportAuthList.js

/**
 *
 * Copyright (C) 2021 Akorbi Digital RMP
 *
 * This file is part of RunMyProcess SDK-JS.
 *
 * RunMyProcess SDK-JS is free software: you can redistribute it and/or modify
 * it under the terms of the Apache License Version 2.0 (the "License");
 *
 *   You may not use this file except in compliance with the License.
 *   You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *   Unless required by applicable law or agreed to in writing, software
 *   distributed under the License is distributed on an "AS IS" BASIS,
 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *   See the License for the specific language governing permissions and
 *   limitations under the License.
 */
  /**
 * Create a new instance of Support_auths
  	@constructor
	@property {Array} authorizations - Array of authorizations.
	@see User
	@see Resource
*/
function UserSupportAuthList(){
	this.authorizations = [];
};
/**
	 @borrows
	 Inherits Resource
*/
UserSupportAuthList.prototype = new  Resource();
/**
	Overrides Resource's loadPreset method.
	@method
	@see Resource#loadPreset
*/
UserSupportAuthList.prototype.loadPreset = function () {
	/**
		Overrides Resource's generateUrl method to return the request url
		@method
		@see Resource#generateUrl
	*/
	this.generateUrl = function () {
		return this.selfUrl;
	};
};
/**
	Overrides Resource's loadSet method to set local variables after request.
	@method
	@param {json} rObject - JSON representation of the loaded data.
	@see Resource#loadSet
*/
UserSupportAuthList.prototype.loadSet = function (rObject) {
	try {
		var father = this;
		father.authorizations = [];
		var ent=father.getArray(rObject, "entry");
		for (var i = 0; i < ent.length; i++) {
			var auth = new UserSupportAuth();
			auth.id = ent[i].id;
			auth.categories = auth.getArray(ent[i], "category");
			auth.title = ent[i].title;
			auth.author.name = ent[i].author.name;
			auth.author.selfUrl = ent[i].author.uri;
			auth.contributor = ent[i].contributor;
			auth.published = ent[i].published;
			auth.updated = ent[i].updated;
			auth.links = auth.getArray(ent[i], "link");
			auth.selfUrl = this.linkSearch("self", auth.links);
			auth.expires = new Date (Resource.removeDecimalsFromDateString(auth.termSearch("expires_on",auth.categories).label));
			father.authorizations.push(auth);
		}
	}catch (e) {
		alert(e);//fix this catch
	};
};
/**
   Create new support authorizations for a specific user.
	@method
	@param {object} options - options to be used during the call<br/>
	@param {Resource~onSuccess} options.onSuccess - a callback function called in case of a success
	@param {Resource~onFailure} [options.onFailure] - a callback function called in case of a failure
	@param {String} [options.baseUrl] - base URL. If not set the current base URL will be used
	@param {String} options.email - email of the user to authorize
	@param {Date} options.expires - expiration daate
 */
UserSupportAuthList.prototype.save = function (options) {
	this.xml = this.generate_xml(options.email,options.expires, options.baseUrl).trim();
	this.resourceSave(options);
};
/**
	Generates a save/update xml to be posted to the server.
	@method
	@param {String} email - The email of the user for the support authorization.
	@param {Date} expires - The expiering date of the support authorization.
	@param {String} baseUrl - base URL. If not set the current base URL will be used.
*/
UserSupportAuthList.prototype.generate_xml = function (email,expires, baseUrl) {
	var v_expires=this.toISOString(expires);
	var v_baseUrl = baseUrl || RMPApplication.getBaseUrl();
	var xml = '<?xml version="1.0" encoding="UTF-8"?>'
				+'<feed xml:base="'+v_baseUrl+'" xmlns:xml="http://www.w3.org/XML/1998/namespace" xmlns="http://www.w3.org/2005/Atom">'
					+'<title/>'
					+'<rights>(c) RunMyProcess</rights>'
					+'<entry>'
						+'<contributor>'
							+'<email>'+email+'</email>'
						+'</contributor>'
						+'<category term="expires_on" label="'+v_expires+'"/>'
					+'</entry>'
				+'</feed>'
				;

	return xml;
};

Index

Classes

  • AccessLog
  • AllLaneUserList
  • AppInstanceReport
  • Context
  • Customer
  • CustomerDomainList
  • CustomerList
  • CustomerSubscriptionList
  • CustomerTrafficList
  • CustomList
  • CustomListList
  • Domain
  • Host
  • HostList
  • HostMode
  • I18n
  • I18nDico
  • Lane
  • LaneList
  • LanePoolList
  • LogLog
  • Metadata
  • Oauth
  • OauthList
  • Pool
  • PoolList
  • Preferences
  • Process
  • ProcessList
  • Project
  • ProjectAppliQuery
  • ProjectChildList
  • ProjectLaneList
  • ProjectList
  • ProjectProcess
  • ProjectProcessList
  • ProjectProcessQuery
  • ProjectVersion
  • ProjectVersionList
  • Report
  • RequestLog
  • Resource
  • SavedQuery
  • Subscription
  • Token
  • Traffic
  • Usage
  • User
  • UserAccessList
  • UserDelegation
  • UserDelegationList
  • UserLaneList
  • UserList
  • UserRepresentationList
  • UserSupportAuth
  • UserSupportAuthList
  • WebInterface
  • WebInterfaceList

Global

  • context

© Akorbi Digital RMP. All Rights Reserved - Legal terms - Contact