Skip to content

Commit 2d0bd18

Browse files
author
Kevin Em
authored
Merge pull request #9 from kevinem/develop
Add ability to change baseUri and version
2 parents 4d1f96a + 3571079 commit 2d0bd18

2 files changed

Lines changed: 62 additions & 23 deletions

File tree

src/AdobeSign.php

Lines changed: 38 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,13 @@ public function getProvider()
7373
public function setAccessToken($accessToken)
7474
{
7575
$this->accessToken = $accessToken;
76+
return $this;
77+
}
78+
79+
public function setVersion($version)
80+
{
81+
$this->version = $version;
82+
return $this;
7683
}
7784

7885
protected function parseResponse($res)
@@ -109,6 +116,12 @@ public function getBaseUris()
109116
return $this->parseResponse($res);
110117
}
111118

119+
public function setBaseUri($baseUri)
120+
{
121+
$this->baseUri = $baseUri;
122+
return $this;
123+
}
124+
112125
/*
113126
* TransientDocuments
114127
*/
@@ -120,7 +133,7 @@ public function uploadTransientDocument(MultipartStream $multipartStream, array
120133
"$this->baseUri/$this->version/transientDocuments",
121134
$this->accessToken, [
122135
'headers' => $headers,
123-
'body' => $multipartStream
136+
'body' => $multipartStream
124137
]
125138
);
126139

@@ -142,7 +155,7 @@ public function createAgreement(array $agreementCreationInfo, array $headers = [
142155
'headers' => array_merge([
143156
'Content-Type' => 'application/json'
144157
], $headers),
145-
'body' => json_encode($agreementCreationInfo)
158+
'body' => json_encode($agreementCreationInfo)
146159
]
147160
);
148161

@@ -157,13 +170,14 @@ public function createAlternateParticipant(
157170
$participantId,
158171
array $alternateParticipantInfo,
159172
array $headers = []
160-
) {
173+
)
174+
{
161175
$request = $this->provider->getAuthenticatedRequest(
162176
'POST',
163177
"$this->baseUri/$this->version/agreements/$agreementId/participantSets/$participantSetId/participants/$participantId/alternateParticipants",
164178
$this->accessToken, [
165179
'headers' => $headers,
166-
'body' => $alternateParticipantInfo
180+
'body' => $alternateParticipantInfo
167181
]
168182
);
169183

@@ -392,7 +406,7 @@ public function updateAgreementStatus($agreementId, array $agreementStatusUpdate
392406
'headers' => array_merge([
393407
'Content-Type' => 'application/json'
394408
], $headers),
395-
'body' => json_encode($agreementStatusUpdateInfo)
409+
'body' => json_encode($agreementStatusUpdateInfo)
396410
]
397411
);
398412

@@ -444,7 +458,7 @@ public function sendReminder(array $reminderCreationInfo, array $headers = [])
444458
'headers' => array_merge([
445459
'Content-Type' => 'application/json'
446460
], $headers),
447-
'body' => json_encode($reminderCreationInfo)
461+
'body' => json_encode($reminderCreationInfo)
448462
]
449463
);
450464

@@ -466,7 +480,7 @@ public function createUser(array $userCreationInfo, array $headers = [])
466480
'headers' => array_merge([
467481
'Content-Type' => 'application/json'
468482
], $headers),
469-
'body' => json_encode($userCreationInfo)
483+
'body' => json_encode($userCreationInfo)
470484
]
471485
);
472486

@@ -520,7 +534,7 @@ public function updateUser($userId, array $userModificationInfo, array $headers
520534
'headers' => array_merge([
521535
'Content-Type' => 'application/json'
522536
], $headers),
523-
'body' => json_encode($userModificationInfo)
537+
'body' => json_encode($userModificationInfo)
524538
]
525539
);
526540

@@ -538,7 +552,7 @@ public function updateUserStatus($userId, array $userStatusUpdateInfo, array $he
538552
'headers' => array_merge([
539553
'Content-Type' => 'application/json'
540554
], $headers),
541-
'body' => json_encode($userStatusUpdateInfo)
555+
'body' => json_encode($userStatusUpdateInfo)
542556
]
543557
);
544558

@@ -560,7 +574,7 @@ public function createLibraryDocument(array $libraryCreationInfo, array $headers
560574
'headers' => array_merge([
561575
'Content-Type' => 'application/json'
562576
], $headers),
563-
'body' => json_encode($libraryCreationInfo)
577+
'body' => json_encode($libraryCreationInfo)
564578
]
565579
);
566580

@@ -687,7 +701,7 @@ public function createWidget(array $widgetCreationRequest, array $headers = [])
687701
'headers' => array_merge([
688702
'Content-Type' => 'application/json'
689703
], $headers),
690-
'body' => json_encode($widgetCreationRequest)
704+
'body' => json_encode($widgetCreationRequest)
691705
]
692706
);
693707

@@ -829,7 +843,7 @@ public function personalizeWidget($widgetId, array $widgetPersonalizationInfo, a
829843
'headers' => array_merge([
830844
'Content-Type' => 'application/json'
831845
], $headers),
832-
'body' => json_encode($widgetPersonalizationInfo)
846+
'body' => json_encode($widgetPersonalizationInfo)
833847
]
834848
);
835849

@@ -847,7 +861,7 @@ public function updateWidgetStatus($widgetId, array $widgetStatusUpdateInfo, arr
847861
'headers' => array_merge([
848862
'Content-Type' => 'application/json'
849863
], $headers),
850-
'body' => json_encode($widgetStatusUpdateInfo)
864+
'body' => json_encode($widgetStatusUpdateInfo)
851865
]
852866
);
853867

@@ -869,7 +883,7 @@ public function getAgreementAssetsViewUrl(array $agreementAssetRequest, array $h
869883
'headers' => array_merge([
870884
'Content-Type' => 'application/json'
871885
], $headers),
872-
'body' => json_encode($agreementAssetRequest)
886+
'body' => json_encode($agreementAssetRequest)
873887
]
874888
);
875889

@@ -887,7 +901,7 @@ public function getAgreementAssetListViewUrl(array $agreementAssetListRequest, a
887901
'headers' => array_merge([
888902
'Content-Type' => 'application/json'
889903
], $headers),
890-
'body' => json_encode($agreementAssetListRequest)
904+
'body' => json_encode($agreementAssetListRequest)
891905
]
892906
);
893907

@@ -905,7 +919,7 @@ public function getSettingsViewUrl(array $targetViewRequest, array $headers = []
905919
'headers' => array_merge([
906920
'Content-Type' => 'application/json'
907921
], $headers),
908-
'body' => json_encode($targetViewRequest)
922+
'body' => json_encode($targetViewRequest)
909923
]
910924
);
911925

@@ -927,7 +941,7 @@ public function createSearchForAgreementAssetEvents(array $agreementAssetEventRe
927941
'headers' => array_merge([
928942
'Content-Type' => 'application/json'
929943
], $headers),
930-
'body' => json_encode($agreementAssetEventRequest)
944+
'body' => json_encode($agreementAssetEventRequest)
931945
]
932946
);
933947

@@ -961,15 +975,16 @@ public function createWorkflowAgreement(
961975
$workflowId,
962976
array $customWorkflowAgreementCreationRequest,
963977
array $headers = []
964-
) {
978+
)
979+
{
965980
$request = $this->provider->getAuthenticatedRequest(
966981
'POST',
967982
"$this->baseUri/$this->version/workflows/$workflowId/agreements",
968983
$this->accessToken, [
969984
'headers' => array_merge([
970985
'Content-Type' => 'application/json'
971986
], $headers),
972-
'body' => json_encode($customWorkflowAgreementCreationRequest)
987+
'body' => json_encode($customWorkflowAgreementCreationRequest)
973988
]
974989
);
975990

@@ -1023,7 +1038,7 @@ public function createGroup(array $groupCreationInfo, array $headers = [])
10231038
'headers' => array_merge([
10241039
'Content-Type' => 'application/json'
10251040
], $headers),
1026-
'body' => json_encode($groupCreationInfo)
1041+
'body' => json_encode($groupCreationInfo)
10271042
]
10281043
);
10291044

@@ -1086,7 +1101,7 @@ public function updateGroup($groupId, array $groupModificationInfo, array $heade
10861101
'headers' => array_merge([
10871102
'Content-Type' => 'application/json'
10881103
], $headers),
1089-
'body' => json_encode($groupModificationInfo)
1104+
'body' => json_encode($groupModificationInfo)
10901105
]
10911106
);
10921107

@@ -1123,7 +1138,7 @@ public function sendMegaSignAgreement(array $megaSignCreationRequest, array $hea
11231138
'headers' => array_merge([
11241139
'Content-Type' => 'application/json'
11251140
], $headers),
1126-
'body' => json_encode($megaSignCreationRequest)
1141+
'body' => json_encode($megaSignCreationRequest)
11271142
]
11281143
);
11291144

@@ -1203,7 +1218,7 @@ public function updateMegaSignStatus($megaSignId, array $megaSignStatusUpdateInf
12031218
'headers' => array_merge([
12041219
'Content-Type' => 'application/json'
12051220
], $headers),
1206-
'body' => json_encode($megaSignStatusUpdateInfo)
1221+
'body' => json_encode($megaSignStatusUpdateInfo)
12071222
]
12081223
);
12091224

tests/BaseTestCase.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,28 @@ protected function setUp()
3535
$this->provider = m::mock('KevinEm\OAuth2\Client\AdobeSign');
3636
$this->adobeSign = new AdobeSign($this->provider);
3737
}
38+
39+
public function testSetBaseUri()
40+
{
41+
$this->adobeSign->setAccessToken('mock_access_token')->setBaseUri('mock_uri');
42+
$this->provider->shouldReceive('getAuthenticatedRequest')->with(
43+
'GET',
44+
"mock_uri/v5/base_uris",
45+
'mock_access_token'
46+
)->andReturn($this->request);
47+
$this->provider->shouldReceive('getResponse')->with($this->request);
48+
$this->adobeSign->getBaseUris();
49+
}
50+
51+
public function testSetVersion()
52+
{
53+
$this->adobeSign->setAccessToken('mock_access_token')->setVersion('mock_version');
54+
$this->provider->shouldReceive('getAuthenticatedRequest')->with(
55+
'GET',
56+
"https://api.na1.echosign.com/api/rest/mock_version/base_uris",
57+
'mock_access_token'
58+
)->andReturn($this->request);
59+
$this->provider->shouldReceive('getResponse')->with($this->request);
60+
$this->adobeSign->getBaseUris();
61+
}
3862
}

0 commit comments

Comments
 (0)