Skip to content
This repository was archived by the owner on Oct 17, 2023. It is now read-only.

Commit c25112c

Browse files
author
Desmond
committed
added file response object, simplified custom fields
1 parent 01974ee commit c25112c

File tree

8 files changed

+87
-11
lines changed

8 files changed

+87
-11
lines changed

HelloSign.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
require_once 'library/HelloSign/EmbeddedSignatureRequest.php';
1313
require_once 'library/HelloSign/Error.php';
1414
require_once 'library/HelloSign/Event.php';
15+
require_once 'library/HelloSign/FileResponse.php';
1516
require_once 'library/HelloSign/OAuthToken.php';
1617
require_once 'library/HelloSign/OAuthTokenRequest.php';
1718
require_once 'library/HelloSign/Signature.php';

library/HelloSign/AbstractObject.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,7 @@ public function toArray($options = array())
7878
foreach ($array as $key => $value) {
7979
if (!$options['include_null'] && $value === null) {
8080
unset($array[$key]);
81-
} elseif ($value instanceof AbstractObject
82-
|| $value instanceof AbstractList) {
81+
} elseif ($value instanceof AbstractObject || $value instanceof AbstractList) {
8382
$array[$key] = $value->toArray();
8483
}
8584
}

library/HelloSign/Client.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,8 @@ public function getFiles($request_id, $dest_path = null, $type = null)
235235
static::SIGNATURE_REQUEST_FILES_PATH . '/' . $request_id,
236236
array('get_url' => true)
237237
);
238+
239+
return new FileResponse($response);
238240
}
239241

240242
return $response;

library/HelloSign/EmbeddedResponse.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,14 @@ class EmbeddedResponse extends AbstractResource
3939
* @ignore
4040
*/
4141
protected $resource_type = 'embedded';
42-
42+
4343
/**
4444
* URL of the signature page to display in the embedded iFrame
4545
*
4646
* @var string
4747
*/
4848
protected $sign_url = null;
49-
49+
5050
/**
5151
* When the link expires
5252
*

library/HelloSign/FileResponse.php

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
<?php
2+
/**
3+
* HelloSign PHP SDK (https://github.com/HelloFax/hellosign-php-sdk/)
4+
*/
5+
6+
/**
7+
* The MIT License (MIT)
8+
*
9+
* Copyright (C) 2014 hellosign.com
10+
*
11+
* Permission is hereby granted, free of charge, to any person obtaining a copy
12+
* of this software and associated documentation files (the "Software"), to deal
13+
* in the Software without restriction, including without limitation the rights
14+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15+
* copies of the Software, and to permit persons to whom the Software is
16+
* furnished to do so, subject to the following conditions:
17+
*
18+
* The above copyright notice and this permission notice shall be included in all
19+
* copies or substantial portions of the Software.
20+
*
21+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27+
* SOFTWARE.
28+
*/
29+
30+
namespace HelloSign;
31+
32+
/**
33+
* Class to hold a file url response
34+
*/
35+
class FileResponse extends AbstractObject
36+
{
37+
/**
38+
* @var string
39+
* @ignore
40+
*/
41+
protected $resource_type = 'file_url';
42+
43+
/**
44+
* URL where the file can be downloaded from
45+
*
46+
* @var string
47+
*/
48+
protected $file_url = null;
49+
50+
/**
51+
* When the link expires
52+
*
53+
* @var integer
54+
*/
55+
protected $expires_at = null;
56+
57+
/**
58+
* @return string
59+
* @ignore
60+
*/
61+
public function getFileUrl()
62+
{
63+
return $this->file_url;
64+
}
65+
66+
/**
67+
* @return integer
68+
* @ignore
69+
*/
70+
public function getExpiresAt()
71+
{
72+
return $this->expires_at;
73+
}
74+
}

library/HelloSign/SignatureRequest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,9 @@ class SignatureRequest extends AbstractSignatureRequest
105105
/**
106106
* A JSON array of Custom Field objects
107107
*
108-
* @var array
108+
* @var string
109109
*/
110-
protected $custom_fields = '[]';
110+
protected $custom_fields = null;
111111

112112
/**
113113
* An array of form field objects containing the name, value, and type of

library/HelloSign/Template.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,9 @@ class Template extends AbstractResource
129129
/**
130130
* A JSON array of Custom Field objects
131131
*
132-
* @var array
132+
* @var string
133133
*/
134-
protected $custom_fields = '[]';
134+
protected $custom_fields = null;
135135

136136
/**
137137
* An array of Merge Field objects containing the name and type of each

library/HelloSign/TemplateSignatureRequest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,9 @@ class TemplateSignatureRequest extends AbstractSignatureRequest
5959
/**
6060
* A JSON array of Custom Field objects
6161
*
62-
* @var array
62+
* @var string
6363
*/
64-
protected $custom_fields = '[]';
64+
protected $custom_fields = null;
6565

6666
/**
6767
* Set the template ID, along with an optional order
@@ -122,7 +122,7 @@ public function setCC($role, $email)
122122
*/
123123
public function setCustomFieldValue($field_name, $value, $editor = null, $required = null)
124124
{
125-
$custom_fields = json_decode($this->custom_fields);
125+
$custom_fields = isset($this->custom_fields) ? json_decode($this->custom_fields) : array();
126126

127127
$custom_fields[] = array(
128128
'name' => $field_name,

0 commit comments

Comments
 (0)