Skip to content
This repository has been archived by the owner on Nov 8, 2022. It is now read-only.

Commit

Permalink
Run php-cs-fixer over codebase
Browse files Browse the repository at this point in the history
  • Loading branch information
harto committed Nov 13, 2015
1 parent 04dae05 commit 9f2083a
Show file tree
Hide file tree
Showing 28 changed files with 1,030 additions and 973 deletions.
283 changes: 154 additions & 129 deletions classes/RightSignature.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,138 +5,163 @@

/**
* A partial implementation of the RightSignature API.
*
* @see https://rightsignature.com/apidocs/overview
*
* @author Stuart Campbell <stuart.campbell@99designs.com>
*/
class RightSignature
{
const API_ENDPOINT = 'https://rightsignature.com';
const API_VERSION = '1.3';

private $_client;

/**
* @param object $client client used to make API GET/POST requests
*/
public static function construct($client)
{
return new self($client);
}

/**
* @param object $client client used to make API GET/POST requests
*/
public function __construct($client)
{
$this->_client = $client;
}

// ----------------------------------------
// Templates

/**
* Returns a document template via the Template Details call.
* @see https://rightsignature.com/apidocs/api_calls?api_method=templateDetails
* @param string $templateGuid template GUID
* @return RightSignature\Template
*/
public function templateDetails($templateGuid)
{
//return Template::details($this->_client, $guid);
}

/**
* Returns a list of templates via the List Templates call.
* @see https://rightsignature.com/apidocs/api_calls?api_method=listTemplates
* @param string $templateGuid template GUID
* @return RightSignature\TemplateList
*/
public function listTemplates()
{
//return Template::list($this->_client);
}

/**
* Creates an intermediate document via the Prepackage Template call.
* @see https://rightsignature.com/apidocs/api_calls?api_method=prepackageTemplate
* @param string $templateGuid template GUID
* @param string $callbackUrl optional callback URL
* @return RightSignature\PrepackagedDocument
*/
public function prepackageTemplate($templateGuid, $callbackUrl=null)
{
return Template::prepackage($this->_client, $templateGuid, $callbackUrl);
}

// ----------------------------------------
// Documents

/**
* Returns document details via the Document Details call.
* @see https://rightsignature.com/apidocs/api_calls?api_method=documentDetails
* @param int $documentGuid document GUID
* @return RightSignature\Document
*/
public function document($documentGuid)
{
return Document::documentDetails($this->_client, $documentGuid);
}

/**
* Return a list of all documents via the List Documents call.
* @see https://rightsignature.com/apidocs/api_calls?api_method=listDocuments
* @return RightSignature\DocumentList
*/
public function documents()
{
// return Document::list($this->_client);
}

// ----------------------------------------
// Signer Links

/**
* Generates signer links (used to generate embedded signing widgets)
* via the Signer Links call (undocumented on RightSignature website).
* @param string $documentGuid sent document GUID
* @param string $returnUrl option URL to redirect user to after signing
* @return RightSignature\SignerLinks
*/
public function signerLinks($documentGuid, $returnUrl=null)
{
return Document::signerLinks($this->_client, $documentGuid, $returnUrl);
}

// ----------------------------------------
// Miscellany

// XXX: Does this belong here?
/**
* Generates a URL for an embedded signing <iframe>.
* @see RightSignature::signerLinks()
* @param string $signerToken signer token
* @param int $widgetHeight optional widget height (px)
* @return string
*/
public static function embeddedWidgetUrl($signerToken, $widgetHeight=null)
{
$args = array("rt=$signerToken");
if ($widgetHeight) $args []= "height=$widgetHeight";

return sprintf('%s/signatures/embedded?%s',
self::API_ENDPOINT,
implode('&', $args)
);
}

/**
* Parse an XML callback string.
* @param string $xml
* @return RightSignature\Callback
*/
public function parseCallback($xml)
{
return RightSignature\Callback::parse($xml);
}
const API_ENDPOINT = 'https://rightsignature.com';
const API_VERSION = '1.3';

private $_client;

/**
* @param object $client client used to make API GET/POST requests
*/
public static function construct($client)
{
return new self($client);
}

/**
* @param object $client client used to make API GET/POST requests
*/
public function __construct($client)
{
$this->_client = $client;
}

// ----------------------------------------
// Templates

/**
* Returns a document template via the Template Details call.
*
* @see https://rightsignature.com/apidocs/api_calls?api_method=templateDetails
*
* @param string $templateGuid template GUID
*
* @return RightSignature\Template
*/
public function templateDetails($templateGuid)
{
//return Template::details($this->_client, $guid);
}

/**
* Returns a list of templates via the List Templates call.
*
* @see https://rightsignature.com/apidocs/api_calls?api_method=listTemplates
*
* @param string $templateGuid template GUID
*
* @return RightSignature\TemplateList
*/
public function listTemplates()
{
//return Template::list($this->_client);
}

/**
* Creates an intermediate document via the Prepackage Template call.
*
* @see https://rightsignature.com/apidocs/api_calls?api_method=prepackageTemplate
*
* @param string $templateGuid template GUID
* @param string $callbackUrl optional callback URL
*
* @return RightSignature\PrepackagedDocument
*/
public function prepackageTemplate($templateGuid, $callbackUrl = null)
{
return Template::prepackage($this->_client, $templateGuid, $callbackUrl);
}

// ----------------------------------------
// Documents

/**
* Returns document details via the Document Details call.
*
* @see https://rightsignature.com/apidocs/api_calls?api_method=documentDetails
*
* @param int $documentGuid document GUID
*
* @return RightSignature\Document
*/
public function document($documentGuid)
{
return Document::documentDetails($this->_client, $documentGuid);
}

/**
* Return a list of all documents via the List Documents call.
*
* @see https://rightsignature.com/apidocs/api_calls?api_method=listDocuments
*
* @return RightSignature\DocumentList
*/
public function documents()
{
// return Document::list($this->_client);
}

// ----------------------------------------
// Signer Links

/**
* Generates signer links (used to generate embedded signing widgets)
* via the Signer Links call (undocumented on RightSignature website).
*
* @param string $documentGuid sent document GUID
* @param string $returnUrl option URL to redirect user to after signing
*
* @return RightSignature\SignerLinks
*/
public function signerLinks($documentGuid, $returnUrl = null)
{
return Document::signerLinks($this->_client, $documentGuid, $returnUrl);
}

// ----------------------------------------
// Miscellany

// XXX: Does this belong here?
/**
* Generates a URL for an embedded signing <iframe>.
*
* @see RightSignature::signerLinks()
*
* @param string $signerToken signer token
* @param int $widgetHeight optional widget height (px)
*
* @return string
*/
public static function embeddedWidgetUrl($signerToken, $widgetHeight = null)
{
$args = array("rt=$signerToken");
if ($widgetHeight) {
$args [] = "height=$widgetHeight";
}

return sprintf('%s/signatures/embedded?%s',
self::API_ENDPOINT,
implode('&', $args)
);
}

/**
* Parse an XML callback string.
*
* @param string $xml
*
* @return RightSignature\Callback
*/
public function parseCallback($xml)
{
return RightSignature\Callback::parse($xml);
}
}
68 changes: 34 additions & 34 deletions classes/RightSignature/Callback.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,43 +2,43 @@

namespace RightSignature;

use \RightSignature\Util\ArrayHelpers as ArrayHelpers;
use \RightSignature\Util\XmlHelpers as XmlHelpers;
use RightSignature\Util\ArrayHelpers as ArrayHelpers;
use RightSignature\Util\XmlHelpers as XmlHelpers;

/**
* A POST callback from RightSignature.
*/
class Callback
extends \RightSignature\Util\ArrayDecorator
extends \RightSignature\Util\ArrayDecorator
{
const TYPE_TEMPLATE = 'Template';
const TYPE_DOCUMENT = 'Document';

const STATUS_CREATED = 'created';
const STATUS_SIGNED = 'signed';

public static function parse($xml)
{
return new self(ArrayHelpers::normaliseKeys(XmlHelpers::toArray($xml)));
}

public function isTemplate()
{
return $this->callback_type == self::TYPE_TEMPLATE;
}

public function isDocument()
{
return $this->callback_type == self::TYPE_DOCUMENT;
}

public function isSigned()
{
return $this->status == self::STATUS_SIGNED;
}

public function isCreated()
{
return $this->status == self::STATUS_CREATED;
}
}
const TYPE_TEMPLATE = 'Template';
const TYPE_DOCUMENT = 'Document';

const STATUS_CREATED = 'created';
const STATUS_SIGNED = 'signed';

public static function parse($xml)
{
return new self(ArrayHelpers::normaliseKeys(XmlHelpers::toArray($xml)));
}

public function isTemplate()
{
return $this->callback_type == self::TYPE_TEMPLATE;
}

public function isDocument()
{
return $this->callback_type == self::TYPE_DOCUMENT;
}

public function isSigned()
{
return $this->status == self::STATUS_SIGNED;
}

public function isCreated()
{
return $this->status == self::STATUS_CREATED;
}
}
Loading

0 comments on commit 9f2083a

Please sign in to comment.