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

Commit 3a69c64

Browse files
author
David Glassanos
authored
Merge pull request #59 from jyoung488/v3
Add functions for API App endpoints
2 parents 0c0d344 + 6930028 commit 3a69c64

File tree

6 files changed

+626
-1
lines changed

6 files changed

+626
-1
lines changed

library/HelloSign/ApiApp.php

Lines changed: 286 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,286 @@
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+
use stdClass;
33+
34+
/**
35+
* Stores HelloSign ApiApp information
36+
*/
37+
class ApiApp extends AbstractResource
38+
{
39+
/**
40+
* @var string
41+
* @ignore
42+
*/
43+
protected $resource_type = 'api_app';
44+
45+
/**
46+
* The client ID of the API App
47+
*
48+
* @var string
49+
*/
50+
protected $client_id = null;
51+
52+
/**
53+
* The domain of the API App
54+
*
55+
* @var string
56+
*/
57+
protected $domain = null;
58+
59+
/**
60+
* The URL that HelloSign events will be POSTed to
61+
*
62+
* @var string
63+
*/
64+
protected $callback_url = null;
65+
66+
/**
67+
* The custom branding logo for the API App
68+
*
69+
* @var string
70+
*/
71+
protected $custom_logo_file = null;
72+
73+
/**
74+
* The name of the API App
75+
*
76+
* @var string
77+
*/
78+
protected $name = null;
79+
80+
/**
81+
* If the API App is approved will return true. Defaults to false.
82+
*
83+
* @var boolean
84+
*/
85+
protected $is_approved = false;
86+
87+
/**
88+
* An object detailing API App owner
89+
*
90+
* account_id: Account ID of owner
91+
* email_address: Email address of owner
92+
*
93+
* @var stdClass
94+
*/
95+
protected $owner_account = null;
96+
97+
/**
98+
* Oauth details
99+
*
100+
* @var string
101+
*/
102+
protected $oauth = ["callback_url" => null, "scopes" => null];
103+
104+
/**
105+
* A JSON array of Custom Field objects
106+
*
107+
* @var string
108+
*/
109+
protected $white_labeling_options = null;
110+
111+
/**
112+
* Key-value pair to set option to allow signer to insert everywhere
113+
* Defaults to true
114+
*
115+
* @var array
116+
*/
117+
protected $options = ["can_insert_everywhere" => true];
118+
119+
120+
/**
121+
* Constructor
122+
*
123+
* @param stdClass $response
124+
* @param array $options
125+
* @see static::fromResponse()
126+
*/
127+
public function __construct($response = null, $options = array())
128+
{
129+
parent::__construct($response, $options);
130+
}
131+
132+
/**
133+
* @return ApiApp
134+
* @ignore
135+
*/
136+
public function setName($name)
137+
{
138+
$this->name = $name;
139+
return $this;
140+
}
141+
142+
/**
143+
* @return string
144+
* @ignore
145+
*/
146+
public function getCallbackUrl()
147+
{
148+
return $this->callback_url;
149+
}
150+
151+
/**
152+
* @return ApiApp
153+
* @ignore
154+
*/
155+
public function setDomain($domain)
156+
{
157+
$this->domain = $domain;
158+
return $this;
159+
}
160+
161+
/**
162+
* @return ApiApp
163+
* @ignore
164+
*/
165+
public function setLogo($file)
166+
{
167+
$this->custom_logo_file = fopen($file, 'rb');
168+
return $this;
169+
}
170+
171+
/**
172+
* @return ApiApp
173+
* @ignore
174+
*/
175+
public function setWhiteLabeling($wl)
176+
{
177+
$this->white_labeling_options = $wl;
178+
return $this;
179+
}
180+
181+
/**
182+
* @return string
183+
* @ignore
184+
*/
185+
public function getClientId()
186+
{
187+
return $this->client_id;
188+
}
189+
190+
/**
191+
* @return string
192+
* @ignore
193+
*/
194+
public function getOwner()
195+
{
196+
return $this->owner_account;
197+
}
198+
199+
/**
200+
* @return boolean
201+
* @ignore
202+
*/
203+
public function isApproved()
204+
{
205+
return $this->is_approved;
206+
}
207+
208+
/**
209+
* @return boolean
210+
* @ignore
211+
*/
212+
public function hasCallbackUrl()
213+
{
214+
return isset($this->callback_url);
215+
}
216+
217+
/**
218+
* @param string $url
219+
* @return ApiApp
220+
* @ignore
221+
*/
222+
public function setCallbackUrl($url)
223+
{
224+
$this->callback_url = $url;
225+
return $this;
226+
}
227+
228+
/**
229+
* @param boolean
230+
* @return ApiApp
231+
* @ignore
232+
*/
233+
public function setInsertEverywhere($insert)
234+
{
235+
$this->options = ["can_insert_everywhere" => $insert];
236+
return $this;
237+
}
238+
239+
/**
240+
* @param string $url
241+
* @param string $scopes
242+
* @return ApiApp
243+
* @ignore
244+
*/
245+
public function setOauthOptions($url, $scopes)
246+
{
247+
$this->oauth = ["callback_url" => $url, "scopes" => $scopes];
248+
return $this;
249+
}
250+
251+
/**
252+
* @return array
253+
* @ignore
254+
*/
255+
public function toCreateParams($options = array())
256+
{
257+
return $this->toArray(array('only' => array(
258+
'name',
259+
'domain',
260+
'callback_url',
261+
'custom_logo_file',
262+
'options',
263+
'oauth',
264+
'white_labeling_options'
265+
)));
266+
}
267+
268+
/**
269+
* @return array
270+
* @ignore
271+
*/
272+
public function toUpdateParams()
273+
{
274+
return $this->toArray(array(
275+
'only' => array(
276+
'name',
277+
'domain',
278+
'callback_url',
279+
'custom_logo_file',
280+
'options',
281+
'oauth',
282+
'white_labeling_options'
283+
)
284+
));
285+
}
286+
}

library/HelloSign/ApiAppList.php

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
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+
* Represents a paged list of HelloSign API Apps
34+
*/
35+
class ApiAppList extends AbstractResourceList
36+
{
37+
/**
38+
* @var string
39+
* @ignore
40+
*/
41+
protected $list_type = 'api_apps';
42+
43+
/**
44+
* @var string
45+
* @ignore
46+
*/
47+
protected $resource_class = 'ApiApp';
48+
}

0 commit comments

Comments
 (0)