Modern Events Calendar Lite - Version 5.9.5

Version Description

12 August 2020 = - Added: A new system to provide ability to change event parameters per occurrence - Added: An ability to set booking limit per different occurrences (pro) - Added: An ability to provide a per event discount for ticket prices to logged users (pro) - Added: Two new placeholders to display next occurrences of booked event (pro) - Added: A new placeholder to generate google calendar link for next occurrences of the booked event (pro) - Added: 3 new messages to the configurable messages in Settings->Messages (pro) - Added: Next occurrences dates of event in booking module when the event is set to Sell All Occurrences By One Booking (pro) - Added: Some hooks to the event link for third party developers - Improved: The dates creation function to dont create dates more than 7 years - Improved: The Buddypress integration to dont show user emails and use their display name and full name (pro) - Improved: The date limit on booking form (pro) - Improved: Booking Settings (pro) - Fixed: Constant Contact Integration (pro) - Fixed: Ticket Variations and blank field (pro) - Fixed: Imported countdown, available spot, and cover shortcakes (pro) - Fixed: An issue when Fluent add-on is not installed - Fixed: Importing advanced repeat events from Google - Fixed: Showing dates in event details page - Fixed: Exporting attendees from the frontend dashboard (pro) - Fixed: Set Google fonts on widgets - Fixed: some PHP notices

Download this release

Release Info

Developer webnus
Plugin Icon 128x128 Modern Events Calendar Lite
Version 5.9.5
Comparing to
See all releases

Code changes from version 5.9.0 to 5.9.5

Files changed (222) hide show
  1. app/api/Ctct/Auth/CtctDataStore.php +37 -0
  2. app/api/Ctct/Auth/CtctOAuth2.php +109 -0
  3. app/api/Ctct/Auth/SessionDataStore.php +60 -0
  4. app/api/Ctct/Components/Account/AccountInfo.php +105 -0
  5. app/api/Ctct/Components/Account/VerifiedEmailAddress.php +41 -0
  6. app/api/Ctct/Components/Activities/Activity.php +77 -0
  7. app/api/Ctct/Components/Activities/ActivityError.php +30 -0
  8. app/api/Ctct/Components/Activities/AddContacts.php +135 -0
  9. app/api/Ctct/Components/Activities/AddContactsImportData.php +67 -0
  10. app/api/Ctct/Components/Activities/ExportContacts.php +39 -0
  11. app/api/Ctct/Components/Component.php +18 -0
  12. app/api/Ctct/Components/Contacts/Address.php +100 -0
  13. app/api/Ctct/Components/Contacts/Contact.php +245 -0
  14. app/api/Ctct/Components/Contacts/ContactList.php +77 -0
  15. app/api/Ctct/Components/Contacts/CustomField.php +37 -0
  16. app/api/Ctct/Components/Contacts/EmailAddress.php +81 -0
  17. app/api/Ctct/Components/Contacts/Note.php +44 -0
  18. app/api/Ctct/Components/EmailMarketing/Campaign.php +321 -0
  19. app/api/Ctct/Components/EmailMarketing/CampaignPreview.php +51 -0
  20. app/api/Ctct/Components/EmailMarketing/ClickThroughDetails.php +44 -0
  21. app/api/Ctct/Components/EmailMarketing/MessageFooter.php +51 -0
  22. app/api/Ctct/Components/EmailMarketing/Schedule.php +48 -0
  23. app/api/Ctct/Components/EmailMarketing/TestSend.php +68 -0
  24. app/api/Ctct/Components/EventSpot/Address.php +103 -0
  25. app/api/Ctct/Components/EventSpot/Contact.php +50 -0
  26. app/api/Ctct/Components/EventSpot/EventFee.php +84 -0
  27. app/api/Ctct/Components/EventSpot/EventSpot.php +366 -0
  28. app/api/Ctct/Components/EventSpot/EventSpotList.php +72 -0
  29. app/api/Ctct/Components/EventSpot/Guest.php +39 -0
  30. app/api/Ctct/Components/EventSpot/GuestSection.php +45 -0
  31. app/api/Ctct/Components/EventSpot/GuestSectionField.php +62 -0
  32. app/api/Ctct/Components/EventSpot/NotificationOption.php +39 -0
  33. app/api/Ctct/Components/EventSpot/OnlineMeeting.php +51 -0
  34. app/api/Ctct/Components/EventSpot/PaymentSummary.php +73 -0
  35. app/api/Ctct/Components/EventSpot/Promocode.php +127 -0
  36. app/api/Ctct/Components/EventSpot/Registrant/Registrant.php +188 -0
  37. app/api/Ctct/Components/EventSpot/Registrant/RegistrantFee.php +76 -0
  38. app/api/Ctct/Components/EventSpot/Registrant/RegistrantOrder.php +67 -0
  39. app/api/Ctct/Components/EventSpot/Registrant/RegistrantPromocode.php +39 -0
  40. app/api/Ctct/Components/EventSpot/Registrant/RegistrantPromocodeInfo.php +75 -0
  41. app/api/Ctct/Components/EventSpot/Registrant/RegistrantSection.php +45 -0
  42. app/api/Ctct/Components/EventSpot/Registrant/RegistrantSectionField.php +65 -0
  43. app/api/Ctct/Components/EventSpot/TrackInformation.php +103 -0
  44. app/api/Ctct/Components/Library/File.php +152 -0
  45. app/api/Ctct/Components/Library/FileUploadStatus.php +43 -0
  46. app/api/Ctct/Components/Library/Folder.php +75 -0
  47. app/api/Ctct/Components/Library/Thumbnail.php +41 -0
  48. app/api/Ctct/Components/ResultSet.php +34 -0
  49. app/api/Ctct/Components/Tracking/BounceActivity.php +40 -0
  50. app/api/Ctct/Components/Tracking/ClickActivity.php +36 -0
  51. app/api/Ctct/Components/Tracking/ForwardActivity.php +35 -0
  52. app/api/Ctct/Components/Tracking/OpenActivity.php +35 -0
  53. app/api/Ctct/Components/Tracking/SendActivity.php +34 -0
  54. app/api/Ctct/Components/Tracking/TrackingActivity.php +27 -0
  55. app/api/Ctct/Components/Tracking/TrackingSummary.php +44 -0
  56. app/api/Ctct/Components/Tracking/UnsubscribeActivity.php +38 -0
  57. app/api/Ctct/ConstantContact.php +98 -0
  58. app/api/Ctct/Exceptions/CtctException.php +32 -0
  59. app/api/Ctct/Exceptions/IllegalArgumentException.php +13 -0
  60. app/api/Ctct/Exceptions/OAuth2Exception.php +11 -0
  61. app/api/Ctct/Services/AccountService.php +111 -0
  62. app/api/Ctct/Services/ActivityService.php +213 -0
  63. app/api/Ctct/Services/BaseService.php +108 -0
  64. app/api/Ctct/Services/CampaignScheduleService.php +139 -0
  65. app/api/Ctct/Services/CampaignTrackingService.php +221 -0
  66. app/api/Ctct/Services/ContactService.php +157 -0
  67. app/api/Ctct/Services/ContactTrackingService.php +221 -0
  68. app/api/Ctct/Services/EmailMarketingService.php +145 -0
  69. app/api/Ctct/Services/EventSpotService.php +329 -0
  70. app/api/Ctct/Services/LibraryService.php +283 -0
  71. app/api/Ctct/Services/ListService.php +117 -0
  72. app/api/Ctct/SplClassLoader.php +130 -0
  73. app/api/Ctct/Util/Config.php +169 -0
  74. app/api/Ctct/WebHooks/CTCTWebhookUtil.php +91 -0
  75. app/api/Ctct/autoload.php +6 -0
  76. app/api/Ctct/vendor.zip +0 -0
  77. app/api/Ctct/vendor/autoload.php +7 -0
  78. app/api/Ctct/vendor/composer/ClassLoader.php +413 -0
  79. app/api/Ctct/vendor/composer/LICENSE +21 -0
  80. app/api/Ctct/vendor/composer/autoload_classmap.php +9 -0
  81. app/api/Ctct/vendor/composer/autoload_files.php +12 -0
  82. app/api/Ctct/vendor/composer/autoload_namespaces.php +10 -0
  83. app/api/Ctct/vendor/composer/autoload_psr4.php +13 -0
  84. app/api/Ctct/vendor/composer/autoload_real.php +59 -0
  85. app/api/Ctct/vendor/composer/installed.json +280 -0
  86. app/api/Ctct/vendor/guzzlehttp/guzzle/.travis.yml +40 -0
  87. app/api/Ctct/vendor/guzzlehttp/guzzle/CHANGELOG.md +1203 -0
  88. app/api/Ctct/vendor/guzzlehttp/guzzle/LICENSE +19 -0
  89. app/api/Ctct/vendor/guzzlehttp/guzzle/README.md +90 -0
  90. app/api/Ctct/vendor/guzzlehttp/guzzle/UPGRADING.md +1203 -0
  91. app/api/Ctct/vendor/guzzlehttp/guzzle/composer.json +41 -0
  92. app/api/Ctct/vendor/guzzlehttp/guzzle/src/Client.php +397 -0
  93. app/api/Ctct/vendor/guzzlehttp/guzzle/src/ClientInterface.php +84 -0
  94. app/api/Ctct/vendor/guzzlehttp/guzzle/src/Cookie/CookieJar.php +277 -0
  95. app/api/Ctct/vendor/guzzlehttp/guzzle/src/Cookie/CookieJarInterface.php +84 -0
  96. app/api/Ctct/vendor/guzzlehttp/guzzle/src/Cookie/FileCookieJar.php +87 -0
  97. app/api/Ctct/vendor/guzzlehttp/guzzle/src/Cookie/SessionCookieJar.php +72 -0
  98. app/api/Ctct/vendor/guzzlehttp/guzzle/src/Cookie/SetCookie.php +404 -0
  99. app/api/Ctct/vendor/guzzlehttp/guzzle/src/Exception/BadResponseException.php +7 -0
  100. app/api/Ctct/vendor/guzzlehttp/guzzle/src/Exception/ClientException.php +7 -0
  101. app/api/Ctct/vendor/guzzlehttp/guzzle/src/Exception/ConnectException.php +37 -0
  102. app/api/Ctct/vendor/guzzlehttp/guzzle/src/Exception/GuzzleException.php +4 -0
  103. app/api/Ctct/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php +188 -0
  104. app/api/Ctct/vendor/guzzlehttp/guzzle/src/Exception/SeekException.php +27 -0
  105. app/api/Ctct/vendor/guzzlehttp/guzzle/src/Exception/ServerException.php +7 -0
  106. app/api/Ctct/vendor/guzzlehttp/guzzle/src/Exception/TooManyRedirectsException.php +4 -0
  107. app/api/Ctct/vendor/guzzlehttp/guzzle/src/Exception/TransferException.php +4 -0
  108. app/api/Ctct/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php +531 -0
  109. app/api/Ctct/vendor/guzzlehttp/guzzle/src/Handler/CurlFactoryInterface.php +27 -0
  110. app/api/Ctct/vendor/guzzlehttp/guzzle/src/Handler/CurlHandler.php +45 -0
  111. app/api/Ctct/vendor/guzzlehttp/guzzle/src/Handler/CurlMultiHandler.php +197 -0
  112. app/api/Ctct/vendor/guzzlehttp/guzzle/src/Handler/EasyHandle.php +87 -0
  113. app/api/Ctct/vendor/guzzlehttp/guzzle/src/Handler/MockHandler.php +176 -0
  114. app/api/Ctct/vendor/guzzlehttp/guzzle/src/Handler/Proxy.php +55 -0
  115. app/api/Ctct/vendor/guzzlehttp/guzzle/src/Handler/StreamHandler.php +458 -0
  116. app/api/Ctct/vendor/guzzlehttp/guzzle/src/HandlerStack.php +273 -0
  117. app/api/Ctct/vendor/guzzlehttp/guzzle/src/MessageFormatter.php +182 -0
  118. app/api/Ctct/vendor/guzzlehttp/guzzle/src/Middleware.php +249 -0
  119. app/api/Ctct/vendor/guzzlehttp/guzzle/src/Pool.php +123 -0
  120. app/api/Ctct/vendor/guzzlehttp/guzzle/src/PrepareBodyMiddleware.php +112 -0
  121. app/api/Ctct/vendor/guzzlehttp/guzzle/src/RedirectMiddleware.php +231 -0
  122. app/api/Ctct/vendor/guzzlehttp/guzzle/src/RequestOptions.php +244 -0
  123. app/api/Ctct/vendor/guzzlehttp/guzzle/src/RetryMiddleware.php +111 -0
  124. app/api/Ctct/vendor/guzzlehttp/guzzle/src/TransferStats.php +126 -0
  125. app/api/Ctct/vendor/guzzlehttp/guzzle/src/UriTemplate.php +241 -0
  126. app/api/Ctct/vendor/guzzlehttp/guzzle/src/functions.php +284 -0
  127. app/api/Ctct/vendor/guzzlehttp/guzzle/src/functions_include.php +6 -0
  128. app/api/Ctct/vendor/guzzlehttp/promises/.gitignore +11 -0
  129. app/api/Ctct/vendor/guzzlehttp/promises/.travis.yml +19 -0
  130. app/api/Ctct/vendor/guzzlehttp/promises/CHANGELOG.md +21 -0
  131. app/api/Ctct/vendor/guzzlehttp/promises/LICENSE +19 -0
  132. app/api/Ctct/vendor/guzzlehttp/promises/Makefile +13 -0
  133. app/api/Ctct/vendor/guzzlehttp/promises/README.md +501 -0
  134. app/api/Ctct/vendor/guzzlehttp/promises/composer.json +31 -0
  135. app/api/Ctct/vendor/guzzlehttp/promises/phpunit.xml.dist +17 -0
  136. app/api/Ctct/vendor/guzzlehttp/promises/src/AggregateException.php +16 -0
  137. app/api/Ctct/vendor/guzzlehttp/promises/src/CancellationException.php +9 -0
  138. app/api/Ctct/vendor/guzzlehttp/promises/src/EachPromise.php +207 -0
  139. app/api/Ctct/vendor/guzzlehttp/promises/src/FulfilledPromise.php +80 -0
  140. app/api/Ctct/vendor/guzzlehttp/promises/src/Promise.php +268 -0
  141. app/api/Ctct/vendor/guzzlehttp/promises/src/PromiseInterface.php +93 -0
  142. app/api/Ctct/vendor/guzzlehttp/promises/src/PromisorInterface.php +15 -0
  143. app/api/Ctct/vendor/guzzlehttp/promises/src/RejectedPromise.php +84 -0
  144. app/api/Ctct/vendor/guzzlehttp/promises/src/RejectionException.php +47 -0
  145. app/api/Ctct/vendor/guzzlehttp/promises/src/TaskQueue.php +79 -0
  146. app/api/Ctct/vendor/guzzlehttp/promises/src/functions.php +495 -0
  147. app/api/Ctct/vendor/guzzlehttp/promises/src/functions_include.php +6 -0
  148. app/api/Ctct/vendor/guzzlehttp/promises/tests/AggregateExceptionTest.php +14 -0
  149. app/api/Ctct/vendor/guzzlehttp/promises/tests/EachPromiseTest.php +294 -0
  150. app/api/Ctct/vendor/guzzlehttp/promises/tests/FulfilledPromiseTest.php +108 -0
  151. app/api/Ctct/vendor/guzzlehttp/promises/tests/NotPromiseInstance.php +50 -0
  152. app/api/Ctct/vendor/guzzlehttp/promises/tests/PromiseTest.php +579 -0
  153. app/api/Ctct/vendor/guzzlehttp/promises/tests/RejectedPromiseTest.php +143 -0
  154. app/api/Ctct/vendor/guzzlehttp/promises/tests/RejectionExceptionTest.php +47 -0
  155. app/api/Ctct/vendor/guzzlehttp/promises/tests/TaskQueueTest.php +31 -0
  156. app/api/Ctct/vendor/guzzlehttp/promises/tests/Thennable.php +24 -0
  157. app/api/Ctct/vendor/guzzlehttp/promises/tests/bootstrap.php +4 -0
  158. app/api/Ctct/vendor/guzzlehttp/promises/tests/functionsTest.php +694 -0
  159. app/api/Ctct/vendor/guzzlehttp/psr7/.gitignore +11 -0
  160. app/api/Ctct/vendor/guzzlehttp/psr7/.travis.yml +20 -0
  161. app/api/Ctct/vendor/guzzlehttp/psr7/CHANGELOG.md +39 -0
  162. app/api/Ctct/vendor/guzzlehttp/psr7/LICENSE +19 -0
  163. app/api/Ctct/vendor/guzzlehttp/psr7/Makefile +29 -0
  164. app/api/Ctct/vendor/guzzlehttp/psr7/README.md +583 -0
  165. app/api/Ctct/vendor/guzzlehttp/psr7/composer.json +35 -0
  166. app/api/Ctct/vendor/guzzlehttp/psr7/phpunit.xml.dist +17 -0
  167. app/api/Ctct/vendor/guzzlehttp/psr7/src/AppendStream.php +233 -0
  168. app/api/Ctct/vendor/guzzlehttp/psr7/src/BufferStream.php +137 -0
  169. app/api/Ctct/vendor/guzzlehttp/psr7/src/CachingStream.php +135 -0
  170. app/api/Ctct/vendor/guzzlehttp/psr7/src/DroppingStream.php +42 -0
  171. app/api/Ctct/vendor/guzzlehttp/psr7/src/FnStream.php +149 -0
  172. app/api/Ctct/vendor/guzzlehttp/psr7/src/InflateStream.php +29 -0
  173. app/api/Ctct/vendor/guzzlehttp/psr7/src/LazyOpenStream.php +39 -0
  174. app/api/Ctct/vendor/guzzlehttp/psr7/src/LimitStream.php +155 -0
  175. app/api/Ctct/vendor/guzzlehttp/psr7/src/MessageTrait.php +158 -0
  176. app/api/Ctct/vendor/guzzlehttp/psr7/src/MultipartStream.php +153 -0
  177. app/api/Ctct/vendor/guzzlehttp/psr7/src/NoSeekStream.php +22 -0
  178. app/api/Ctct/vendor/guzzlehttp/psr7/src/PumpStream.php +165 -0
  179. app/api/Ctct/vendor/guzzlehttp/psr7/src/Request.php +149 -0
  180. app/api/Ctct/vendor/guzzlehttp/psr7/src/Response.php +131 -0
  181. app/api/Ctct/vendor/guzzlehttp/psr7/src/Stream.php +245 -0
  182. app/api/Ctct/vendor/guzzlehttp/psr7/src/StreamDecoratorTrait.php +149 -0
  183. app/api/Ctct/vendor/guzzlehttp/psr7/src/StreamWrapper.php +121 -0
  184. app/api/Ctct/vendor/guzzlehttp/psr7/src/Uri.php +606 -0
  185. app/api/Ctct/vendor/guzzlehttp/psr7/src/functions.php +810 -0
  186. app/api/Ctct/vendor/guzzlehttp/psr7/src/functions_include.php +6 -0
  187. app/api/Ctct/vendor/guzzlehttp/psr7/tests/AppendStreamTest.php +186 -0
  188. app/api/Ctct/vendor/guzzlehttp/psr7/tests/BufferStreamTest.php +63 -0
  189. app/api/Ctct/vendor/guzzlehttp/psr7/tests/CachingStreamTest.php +166 -0
  190. app/api/Ctct/vendor/guzzlehttp/psr7/tests/DroppingStreamTest.php +26 -0
  191. app/api/Ctct/vendor/guzzlehttp/psr7/tests/FnStreamTest.php +90 -0
  192. app/api/Ctct/vendor/guzzlehttp/psr7/tests/FunctionsTest.php +596 -0
  193. app/api/Ctct/vendor/guzzlehttp/psr7/tests/InflateStreamTest.php +16 -0
  194. app/api/Ctct/vendor/guzzlehttp/psr7/tests/LazyOpenStreamTest.php +64 -0
  195. app/api/Ctct/vendor/guzzlehttp/psr7/tests/LimitStreamTest.php +166 -0
  196. app/api/Ctct/vendor/guzzlehttp/psr7/tests/MultipartStreamTest.php +214 -0
  197. app/api/Ctct/vendor/guzzlehttp/psr7/tests/NoSeekStreamTest.php +40 -0
  198. app/api/Ctct/vendor/guzzlehttp/psr7/tests/PumpStreamTest.php +72 -0
  199. app/api/Ctct/vendor/guzzlehttp/psr7/tests/RequestTest.php +157 -0
  200. app/api/Ctct/vendor/guzzlehttp/psr7/tests/ResponseTest.php +146 -0
  201. app/api/Ctct/vendor/guzzlehttp/psr7/tests/StreamDecoratorTraitTest.php +137 -0
  202. app/api/Ctct/vendor/guzzlehttp/psr7/tests/StreamTest.php +161 -0
  203. app/api/Ctct/vendor/guzzlehttp/psr7/tests/StreamWrapperTest.php +100 -0
  204. app/api/Ctct/vendor/guzzlehttp/psr7/tests/UriTest.php +281 -0
  205. app/api/Ctct/vendor/guzzlehttp/psr7/tests/bootstrap.php +11 -0
  206. app/api/Ctct/vendor/psr/http-message/LICENSE +19 -0
  207. app/api/Ctct/vendor/psr/http-message/README.md +13 -0
  208. app/api/Ctct/vendor/psr/http-message/composer.json +25 -0
  209. app/api/Ctct/vendor/psr/http-message/src/MessageInterface.php +187 -0
  210. app/api/Ctct/vendor/psr/http-message/src/RequestInterface.php +129 -0
  211. app/api/Ctct/vendor/psr/http-message/src/ResponseInterface.php +68 -0
  212. app/api/Ctct/vendor/psr/http-message/src/ServerRequestInterface.php +261 -0
  213. app/api/Ctct/vendor/psr/http-message/src/StreamInterface.php +158 -0
  214. app/api/Ctct/vendor/psr/http-message/src/UploadedFileInterface.php +123 -0
  215. app/api/Ctct/vendor/psr/http-message/src/UriInterface.php +323 -0
  216. app/features/dlfile.php +1 -1
  217. app/features/events.php +23 -5
  218. app/features/fes.php +5 -2
  219. app/features/ix.php +29 -14
  220. app/features/labels.php +1 -1
  221. app/features/mec.php +76 -29
  222. app/features/mec/booking.php +7 -33
app/api/Ctct/Auth/CtctDataStore.php ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Ctct\Auth;
3
+
4
+ /**
5
+ * Interface containing the necessary functionality to manage an OAuth2 data store
6
+ *
7
+ * @package Auth
8
+ * @author Constant Contact
9
+ */
10
+
11
+ interface CtctDataStore {
12
+ /**
13
+ * Add a new user to the data store
14
+ * @param $id - unique identifier
15
+ * @param array $params - additional parameters
16
+ */
17
+ public function addUser($id, array $params);
18
+
19
+ /**
20
+ * Get an existing user from the data store
21
+ * @param $id - unique identifier
22
+ */
23
+ public function getUser($id);
24
+
25
+ /**
26
+ * Update an existing user in the data store
27
+ * @param $id - unique identifier
28
+ * @param array $params - additional parameters
29
+ */
30
+ public function updateUser($id, array $params);
31
+
32
+ /**
33
+ * Delete an existing user from the data store
34
+ * @param $id - unique identifier
35
+ */
36
+ public function deleteUser($id);
37
+ }
app/api/Ctct/Auth/CtctOAuth2.php ADDED
@@ -0,0 +1,109 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Ctct\Auth;
3
+
4
+ use Ctct\Exceptions\CtctException;
5
+ use Ctct\Exceptions\OAuth2Exception;
6
+ use Ctct\Util\Config;
7
+ use GuzzleHttp\Client;
8
+ use GuzzleHttp\Exception\ClientException;
9
+
10
+ /**
11
+ * Class that implements necessary functionality to obtain an access token from a user
12
+ *
13
+ * @package Auth
14
+ * @author Constant Contact
15
+ */
16
+ class CtctOAuth2 {
17
+ public $clientId;
18
+ public $clientSecret;
19
+ public $redirectUri;
20
+ public $client;
21
+ public $props;
22
+
23
+ public function __construct($clientId, $clientSecret, $redirectUri) {
24
+ $this->clientId = $clientId;
25
+ $this->clientSecret = $clientSecret;
26
+ $this->redirectUri = $redirectUri;
27
+ $this->client = new Client();
28
+ }
29
+
30
+ /**
31
+ * Get the URL at which the user can authenticate and authorize the requesting application
32
+ * @param boolean $server - Whether or not to use OAuth2 server flow, alternative is client flow
33
+ * @param string $state - An optional value used by the client to maintain state between the request and callback.
34
+ * @return string $url - The url to send a user to, to grant access to their account
35
+ */
36
+ public function getAuthorizationUrl($server = true, $state = null) {
37
+ $responseType = ($server) ? Config::get('auth.response_type_code') : Config::get("auth.response_type_token");
38
+ $params = array(
39
+ 'response_type' => $responseType,
40
+ 'client_id' => $this->clientId,
41
+ 'redirect_uri' => $this->redirectUri
42
+ );
43
+
44
+ // add the state param if it was provided
45
+ if ($state != null) {
46
+ $params['state'] = $state;
47
+ }
48
+
49
+ $baseUrl = Config::get('auth.base_url') . Config::get('auth.authorization_endpoint');
50
+ $query = http_build_query($params, '', '&', PHP_QUERY_RFC3986);
51
+ return $baseUrl . "?" . $query;
52
+ }
53
+
54
+ /**
55
+ * Obtain an access token
56
+ * @param string $code - code returned from Constant Contact after a user has granted access to their account
57
+ * @return array
58
+ * @throws OAuth2Exception
59
+ */
60
+ public function getAccessToken($code) {
61
+ $params = array(
62
+ 'grant_type' => Config::get('auth.authorization_code_grant_type'),
63
+ 'client_id' => $this->clientId,
64
+ 'client_secret' => $this->clientSecret,
65
+ 'code' => $code,
66
+ 'redirect_uri' => $this->redirectUri
67
+ );
68
+
69
+ $baseUrl = Config::get('auth.base_url') . Config::get('auth.token_endpoint');
70
+ try {
71
+ $response = json_decode($this->client->request('POST', $baseUrl, [
72
+ 'query' => $params
73
+ ])->getBody(), true);
74
+ } catch (ClientException $e) {
75
+ throw $this->convertException($e);
76
+ }
77
+
78
+ return $response;
79
+ }
80
+
81
+ /**
82
+ * @param ClientException $exception
83
+ * @return OAuth2Exception
84
+ */
85
+ private function convertException($exception) {
86
+ $oauth2Exception = new OAuth2Exception($exception->getResponse()->getReasonPhrase(), $exception->getCode());
87
+ $oauth2Exception->setErrors(json_decode($exception->getResponse()->getBody()->getContents(), true));
88
+ return $oauth2Exception;
89
+ }
90
+
91
+ /**
92
+ * Get an information about an access token
93
+ * @param string $accessToken - Constant Contact OAuth2 access token
94
+ * @return array
95
+ * @throws CtctException
96
+ */
97
+ public function getTokenInfo($accessToken) {
98
+ $baseUrl = Config::get('auth.base_url') . Config::get('auth.token_info');
99
+
100
+ try {
101
+ $response = json_decode($this->client->request('POST', $baseUrl, [
102
+ 'query' => array("access_token" => $accessToken)
103
+ ])->getBody(), true);
104
+ } catch (ClientException $e) {
105
+ throw $this->convertException($e);
106
+ }
107
+ return $response;
108
+ }
109
+ }
app/api/Ctct/Auth/SessionDataStore.php ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Ctct\Auth;
3
+
4
+ /**
5
+ * Example implementation of the CTCTDataStore interface that uses session for access token storage
6
+ *
7
+ * @package Auth
8
+ * @author Constant Contact
9
+ */
10
+ class SessionDataStore implements CtctDataStore {
11
+ public function __construct() {
12
+ session_start();
13
+
14
+ if (!isset($_SESSION['datastore'])) {
15
+ $_SESSION['datastore'] = array();
16
+ }
17
+
18
+ }
19
+
20
+ /**
21
+ * Add a new user to the data store
22
+ * @param string $username - Constant Contact username
23
+ * @param array $params - additional parameters
24
+ */
25
+ public function addUser($username, array $params) {
26
+ $_SESSION['datastore'][$username] = $params;
27
+ }
28
+
29
+ /**
30
+ * Get an existing user from the data store
31
+ * @param string $username - Constant Contact username
32
+ * @return Array params of the username in the datastore, or false if the username doesn't exist
33
+ */
34
+ public function getUser($username) {
35
+ if (array_key_exists($username, $_SESSION['datastore'])) {
36
+ return $_SESSION['datastore'][$username];
37
+ } else {
38
+ return false;
39
+ }
40
+ }
41
+
42
+ /**
43
+ * Update an existing user in the data store
44
+ * @param string $username - Constant Contact username
45
+ * @param array $params - additional parameters
46
+ */
47
+ public function updateUser($username, array $params) {
48
+ if (array_key_exists($username, $_SESSION['datastore'])) {
49
+ $_SESSION['datastore'][$username] = $params;
50
+ }
51
+ }
52
+
53
+ /**
54
+ * Delete an existing user from the data store
55
+ * @param string $username - Constant Contact username
56
+ */
57
+ public function deleteUser($username) {
58
+ unset($_SESSION['datastore'][$username]);
59
+ }
60
+ }
app/api/Ctct/Components/Account/AccountInfo.php ADDED
@@ -0,0 +1,105 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Ctct\Components\Account;
3
+
4
+ use Ctct\Components\Component;
5
+
6
+ /**
7
+ * Represents account info associated with an access token in Constant Contact
8
+ *
9
+ * @package Components
10
+ * @subpackage Account
11
+ * @author ewaltman
12
+ */
13
+ class AccountInfo extends Component {
14
+ /**
15
+ * Website associated with the account
16
+ * @var string
17
+ */
18
+ public $website;
19
+
20
+ /**
21
+ * Name of organization associated with the account
22
+ * @var string
23
+ */
24
+ public $organization_name;
25
+
26
+ /**
27
+ * Time zone used with the account
28
+ * @var string
29
+ */
30
+ public $time_zone;
31
+
32
+ /**
33
+ * First name of the account user
34
+ * @var string
35
+ */
36
+ public $first_name;
37
+
38
+ /**
39
+ * Last name of the account user
40
+ * @var string
41
+ */
42
+ public $last_name;
43
+
44
+ /**
45
+ * Email address associated with the account
46
+ * @var string
47
+ */
48
+ public $email;
49
+
50
+ /**
51
+ * Phone number associated with the account
52
+ * @var string
53
+ */
54
+ public $phone;
55
+
56
+ /**
57
+ * URL of the company logo associated with the account
58
+ * @var string
59
+ */
60
+ public $company_logo;
61
+
62
+ /**
63
+ * Country code associated with the account
64
+ * @var string
65
+ */
66
+ public $country_code;
67
+
68
+ /**
69
+ * State code associated with the account
70
+ * @var string
71
+ */
72
+ public $state_code;
73
+
74
+ /**
75
+ * Array of organization addresses associated with the account
76
+ * @var array
77
+ */
78
+ public $organization_addresses;
79
+
80
+ /**
81
+ * Factory method to create an AccountInfo object from an array
82
+ * @param array $props - associative array of initial properties to set
83
+ * @return AccountInfo
84
+ */
85
+ public static function create(array $props) {
86
+ $accountInfo = new AccountInfo();
87
+ $accountInfo->website = parent::getValue($props, "website");
88
+ $accountInfo->organization_name = parent::getValue($props, "organization_name");
89
+ $accountInfo->time_zone = parent::getValue($props, "time_zone");
90
+ $accountInfo->first_name = parent::getValue($props, "first_name");
91
+ $accountInfo->last_name = parent::getValue($props, "last_name");
92
+ $accountInfo->email = parent::getValue($props, "email");
93
+ $accountInfo->phone = parent::getValue($props, "phone");
94
+ $accountInfo->company_logo = parent::getValue($props, "company_logo");
95
+ $accountInfo->country_code = parent::getValue($props, "country_code");
96
+ $accountInfo->state_code = parent::getValue($props, "state_code");
97
+ $accountInfo->organization_addresses = parent::getValue($props, "organization_addresses");
98
+
99
+ return $accountInfo;
100
+ }
101
+
102
+ public function toJson() {
103
+ return json_encode($this);
104
+ }
105
+ }
app/api/Ctct/Components/Account/VerifiedEmailAddress.php ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Ctct\Components\Account;
3
+
4
+ use Ctct\Components\Component;
5
+
6
+ /**
7
+ * Represents a single Verified Email Address in Constant Contact
8
+ *
9
+ * @package Components
10
+ * @subpackage Account
11
+ * @author Constant Contact
12
+ */
13
+ class VerifiedEmailAddress extends Component {
14
+ /**
15
+ * Email Address associated with the account
16
+ * @var string
17
+ */
18
+ public $email_address;
19
+
20
+ /**
21
+ * Status of the verified email address
22
+ * @var string
23
+ */
24
+ public $status;
25
+
26
+ /**
27
+ * Factory method to create an VerifiedEmail object from an array
28
+ * @param array $props - associative array of initial properties to set
29
+ * @return VerifiedEmailAddress
30
+ */
31
+ public static function create(array $props) {
32
+ $verifiedAddress = new VerifiedEmailAddress();
33
+ $verifiedAddress->email_address = parent::getValue($props, "email_address");
34
+ $verifiedAddress->status = parent::getValue($props, "status");
35
+ return $verifiedAddress;
36
+ }
37
+
38
+ public function toJson() {
39
+ return json_encode($this);
40
+ }
41
+ }
app/api/Ctct/Components/Activities/Activity.php ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Ctct\Components\Activities;
3
+
4
+ use Ctct\Components\Component;
5
+
6
+ /**
7
+ * Represents a single Activity in Constant Contact
8
+ *
9
+ * @package Components
10
+ * @subpackage Activities
11
+ * @author Constant Contact
12
+ */
13
+ class Activity extends Component {
14
+ public $id;
15
+ public $type;
16
+ public $status;
17
+ public $start_date;
18
+ public $finish_date;
19
+ public $file_name;
20
+ public $created_date;
21
+ public $error_count;
22
+ public $errors = array();
23
+ public $warnings = array();
24
+ public $contact_count;
25
+
26
+ /**
27
+ * Factory method to create an Activity object from an array
28
+ * @param array $props - associative array of initial properties to set
29
+ * @return Activity
30
+ */
31
+ public static function create(array $props) {
32
+ $activity = new Activity();
33
+ $activity->id = parent::getValue($props, "id");
34
+ $activity->type = parent::getValue($props, "type");
35
+ $activity->status = parent::getValue($props, "status");
36
+ $activity->start_date = parent::getValue($props, "start_date");
37
+ $activity->finish_date = parent::getValue($props, "finish_date");
38
+ $activity->created_date = parent::getValue($props, "created_date");
39
+ $activity->error_count = parent::getValue($props, "error_count");
40
+ $activity->contact_count = parent::getValue($props, "contact_count");
41
+
42
+ // set any errors that exist, otherwise destroy the property
43
+ if (array_key_exists('errors', $props)) {
44
+ foreach ($props['errors'] as $error) {
45
+ $activity->errors[] = ActivityError::create($error);
46
+ }
47
+ } else {
48
+ unset($activity->errors);
49
+ }
50
+
51
+ // set any warnings that exist, otherwise destroy the property
52
+ if (array_key_exists('warnings', $props)) {
53
+ foreach ($props['warnings'] as $error) {
54
+ $activity->warnings[] = ActivityError::create($error);
55
+ }
56
+ } else {
57
+ unset($activity->warnings);
58
+ }
59
+
60
+ // set the file name if exists
61
+ if (array_key_exists('file_name', $props)) {
62
+ $activity->file_name = $props['file_name'];
63
+ } else {
64
+ unset($activity->file_name);
65
+ }
66
+
67
+ return $activity;
68
+ }
69
+
70
+ /**
71
+ * Create json used for a POST/PUT request, also handles removing attributes that will cause errors if sent
72
+ * @return string
73
+ */
74
+ public function toJson() {
75
+ return json_encode($this);
76
+ }
77
+ }
app/api/Ctct/Components/Activities/ActivityError.php ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Ctct\Components\Activities;
3
+
4
+ use Ctct\Components\Component;
5
+
6
+ /**
7
+ * Represents a single Activity Error in Constant Contact
8
+ *
9
+ * @package Components
10
+ * @subpackage Activities
11
+ * @author Constant Contact
12
+ */
13
+ class ActivityError extends Component {
14
+ public $message;
15
+ public $line_number;
16
+ public $email_address;
17
+
18
+ /**
19
+ * Factory method to create an object from an array
20
+ * @param array $props - associative array of initial properties to set
21
+ * @return ActivityError
22
+ */
23
+ public static function create(array $props) {
24
+ $activityError = new ActivityError();
25
+ $activityError->message = parent::getValue($props, "message");
26
+ $activityError->line_number = parent::getValue($props, "line_number");
27
+ $activityError->email_address = parent::getValue($props, "email_address");
28
+ return $activityError;
29
+ }
30
+ }
app/api/Ctct/Components/Activities/AddContacts.php ADDED
@@ -0,0 +1,135 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Ctct\Components\Activities;
3
+
4
+ use Ctct\Components\Component;
5
+ use Ctct\Exceptions\IllegalArgumentException;
6
+ use Ctct\Util\Config;
7
+
8
+ /**
9
+ * Represents an AddContacts Activity
10
+ *
11
+ * @package Components
12
+ * @subpackage Activities
13
+ * @author Constant Contact
14
+ */
15
+ class AddContacts extends Component {
16
+ public $import_data = array();
17
+ public $lists = array();
18
+ public $column_names = array();
19
+
20
+ public function __construct(Array $contacts, Array $lists, Array $columnNames = array()) {
21
+ if (!empty($contacts)) {
22
+ if ($contacts[0] instanceof AddContactsImportData) {
23
+ $this->import_data = $contacts;
24
+ } else {
25
+ $msg = sprintf(Config::get('errors.id_or_object'), "AddContactsImportData");
26
+ throw new IllegalArgumentException($msg);
27
+ }
28
+ }
29
+
30
+ $this->lists = $lists;
31
+
32
+ if (empty($columnNames)) {
33
+ $usedColumns[] = Config::get('activities_columns.email');
34
+ $contact = $contacts[0];
35
+
36
+ if (isset($contact->first_name)) {
37
+ $usedColumns[] = Config::get('activities_columns.first_name');
38
+ }
39
+ if (isset($contact->last_name)) {
40
+ $usedColumns[] = Config::get('activities_columns.last_name');
41
+ }
42
+ if (isset($contact->birthday_day)) {
43
+ $usedColumns[] = Config::get('activities_columns.birthday_day');
44
+ }
45
+ if (isset($contact->birthday_month)) {
46
+ $usedColumns[] = Config::get('activities_columns.birthday_month');
47
+ }
48
+ if (isset($contact->anniversary)) {
49
+ $usedColumns[] = Config::get('activities_columns.anniversary');
50
+ }
51
+ if (isset($contact->job_title)) {
52
+ $usedColumns[] = Config::get('activities_columns.job_title');
53
+ }
54
+ if (isset($contact->company_name)) {
55
+ $usedColumns[] = Config::get('activities_columns.company_name');
56
+ }
57
+ if (isset($contact->work_phone)) {
58
+ $usedColumns[] = Config::get('activities_columns.work_phone');
59
+ }
60
+ if (isset($contact->home_phone)) {
61
+ $usedColumns[] = Config::get('activities_columns.home_phone');
62
+ }
63
+
64
+ if (isset($contact->birthday_day)) {
65
+ $usedColumns[] = Config::get('activities_columns.birthday_day');
66
+ }
67
+ if (isset($contact->birthday_month)) {
68
+ $usedColumns[] = Config::get('activities_columns.birthday_month');
69
+ }
70
+ if (isset($contact->anniversary)) {
71
+ $usedColumns[] = Config::get('activities_columns.anniversary');
72
+ }
73
+
74
+ // Addresses
75
+ if (!empty($contact->addresses)) {
76
+ $address = $contact->addresses[0];
77
+ if (isset($address->line1)) {
78
+ $usedColumns[] = Config::get('activities_columns.address1');
79
+ }
80
+ if (isset($address->line2)) {
81
+ $usedColumns[] = Config::get('activities_columns.address2');
82
+ }
83
+ if (isset($address->line3)) {
84
+ $usedColumns[] = Config::get('activities_columns.address3');
85
+ }
86
+ if (isset($address->city)) {
87
+ $usedColumns[] = Config::get('activities_columns.city');
88
+ }
89
+ if (isset($address->state_code)) {
90
+ $usedColumns[] = Config::get('activities_columns.state');
91
+ }
92
+ if (isset($address->state_province)) {
93
+ $usedColumns[] = Config::get('activities_columns.state_province');
94
+ }
95
+ if (isset($address->country)) {
96
+ $usedColumns[] = Config::get('activities_columns.country');
97
+ }
98
+ if (isset($address->postal_code)) {
99
+ $usedColumns[] = Config::get('activities_columns.postal_code');
100
+ }
101
+ if (isset($address->sub_postal_code)) {
102
+ $usedColumns[] = Config::get('activities_columns.sub_postal_code');
103
+ }
104
+ }
105
+
106
+ // Custom Fields
107
+ if (!empty($contact->custom_fields)) {
108
+ foreach ($contact->custom_fields as $customField) {
109
+ if (strpos($customField->name, 'custom_field_') !== false) {
110
+ $customFieldNumber = substr($customField->name, 13);
111
+ $usedColumns[] = Config::get('activities_columns.custom_field_' . $customFieldNumber);
112
+ }
113
+ }
114
+ }
115
+ $this->column_names = $usedColumns;
116
+ } else {
117
+ $this->column_names = $columnNames;
118
+ }
119
+ }
120
+
121
+ /**
122
+ * Turn the object into json, removing any extra fields
123
+ * @return string
124
+ */
125
+ public function toJson() {
126
+ foreach ($this->import_data as $contact) {
127
+ foreach ($contact as $key => $value) {
128
+ if ($value == null) {
129
+ unset($contact->$key);
130
+ }
131
+ }
132
+ }
133
+ return json_encode($this);
134
+ }
135
+ }
app/api/Ctct/Components/Activities/AddContactsImportData.php ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Ctct\Components\Activities;
3
+
4
+ use Ctct\Components\Component;
5
+ use Ctct\Components\Contacts\Address;
6
+ use Ctct\Components\Contacts\CustomField;
7
+
8
+ /**
9
+ * Represents a single Activity in Constant Contact
10
+ *
11
+ * @package Components
12
+ * @subpackage Activities
13
+ * @author Constant Contact
14
+ */
15
+ class AddContactsImportData extends Component {
16
+ public $first_name;
17
+ public $middle_name;
18
+ public $last_name;
19
+ public $job_title;
20
+ public $company_name;
21
+ public $work_phone;
22
+ public $home_phone;
23
+
24
+ public $birthday_day;
25
+ public $birthday_month;
26
+ public $anniversary;
27
+
28
+ public $email_addresses = array();
29
+ public $addresses = array();
30
+ public $custom_fields = array();
31
+
32
+ /**
33
+ * Factory method to create an Activity object from an array
34
+ * @param array $props - associative array of initial properties to set
35
+ */
36
+ public function __construct(array $props = array()) {
37
+ foreach ($this as $property => $value) {
38
+ $this->$property = parent::getValue($props, $property);
39
+ }
40
+ }
41
+
42
+ public function addCustomField(CustomField $customField) {
43
+ $this->custom_fields[] = $customField;
44
+ }
45
+
46
+ public function addAddress(Address $address) {
47
+ if (isset($address->state)) {
48
+ $address->state_code = $address->state;
49
+ unset($address->state);
50
+ }
51
+
52
+ foreach ($address as $key => $value) {
53
+ if ($value == null) {
54
+ unset($address->$key);
55
+ }
56
+ }
57
+ $this->addresses[] = $address;
58
+ }
59
+
60
+ public function addEmail($emailAddress) {
61
+ $this->email_addresses[] = $emailAddress;
62
+ }
63
+
64
+ public function toJson() {
65
+ return json_encode($this);
66
+ }
67
+ }
app/api/Ctct/Components/Activities/ExportContacts.php ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Ctct\Components\Activities;
3
+
4
+ use Ctct\Components\Component;
5
+
6
+ /**
7
+ * Represents an Export Contacts Activity in Constant Contact
8
+ *
9
+ * @package Components
10
+ * @subpackage Activities
11
+ * @author Constant Contact
12
+ */
13
+ class ExportContacts extends Component {
14
+ public $file_type = "CSV";
15
+ public $sort_by = "EMAIL_ADDRESS";
16
+ public $export_date_added = true;
17
+ public $export_added_by = true;
18
+ public $lists = array();
19
+ public $column_names = array("Email Address", "First Name", "Last Name");
20
+
21
+ /**
22
+ * Constructor
23
+ * @param array $lists - array of list id's to export from
24
+ * @return ExportContacts
25
+ */
26
+ public function __construct(Array $lists = null) {
27
+ if (!$lists == null) {
28
+ $this->lists = $lists;
29
+ }
30
+ }
31
+
32
+ /**
33
+ * Create json used for a POST/PUT request, also handles removing attributes that will cause errors if sent
34
+ * @return string
35
+ */
36
+ public function toJson() {
37
+ return json_encode($this);
38
+ }
39
+ }
app/api/Ctct/Components/Component.php ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Ctct\Components;
3
+
4
+ /**
5
+ * Super class for all components
6
+ */
7
+ abstract class Component {
8
+ /**
9
+ * Get the requested value from an array, or return the default
10
+ * @param array $array - array to search for the provided array key
11
+ * @param string $item - array key to look for
12
+ * @param string $default - value to return if the item is not found, default is null
13
+ * @return mixed
14
+ */
15
+ protected static function getValue(array $array, $item, $default = null) {
16
+ return (isset($array[$item])) ? $array[$item] : $default;
17
+ }
18
+ }
app/api/Ctct/Components/Contacts/Address.php ADDED
@@ -0,0 +1,100 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Ctct\Components\Contacts;
3
+
4
+ use Ctct\Components\Component;
5
+
6
+ /**
7
+ * Represents a single Address of a Contact
8
+ *
9
+ * @package Components
10
+ * @subpackage Contacts
11
+ * @author Constant Contact
12
+ */
13
+ class Address extends Component {
14
+ /**
15
+ * Id of the address
16
+ * @var string
17
+ */
18
+ public $id;
19
+
20
+ /**
21
+ * Line 1 of the address
22
+ * @var string
23
+ */
24
+ public $line1;
25
+
26
+ /**
27
+ * Line 2 of the address
28
+ * @var string
29
+ */
30
+ public $line2;
31
+
32
+ /**
33
+ * Line 3 of the address
34
+ * @var string
35
+ */
36
+ public $line3;
37
+
38
+ /**
39
+ * City info for this address
40
+ * @var string
41
+ */
42
+ public $city;
43
+
44
+ /**
45
+ * Address type, must be one of "BUSINESS", "PERSONAL", or "UNKNOWN"
46
+ * @var string
47
+ */
48
+ public $address_type;
49
+
50
+ /**
51
+ * The state code for this address
52
+ * @var string
53
+ */
54
+ public $state_code;
55
+
56
+ /**
57
+ * The state for this address (non-US/Canada)
58
+ *
59
+ */
60
+ public $state;
61
+
62
+ /**
63
+ * The country code for this address
64
+ * @var string
65
+ */
66
+ public $country_code;
67
+
68
+ /**
69
+ * The postal code for this address
70
+ * @var string
71
+ */
72
+ public $postal_code;
73
+
74
+ /**
75
+ * The sub postal code for this address
76
+ * @var string
77
+ */
78
+ public $sub_postal_code;
79
+
80
+ /**
81
+ * Factory method to create an Address object from an array
82
+ * @param array $props - Associative array of initial properties to set
83
+ * @return Address
84
+ */
85
+ public static function create(array $props) {
86
+ $address = new Address();
87
+ $address->id = parent::getValue($props, "id");
88
+ $address->line1 = parent::getValue($props, "line1");
89
+ $address->line2 = parent::getValue($props, "line2");
90
+ $address->line3 = parent::getValue($props, "line3");
91
+ $address->city = parent::getValue($props, "city");
92
+ $address->address_type = parent::getValue($props, "address_type");
93
+ $address->state_code = parent::getValue($props, "state_code");
94
+ $address->state = parent::getValue($props, "state");
95
+ $address->country_code = parent::getValue($props, "country_code");
96
+ $address->postal_code = parent::getValue($props, "postal_code");
97
+ $address->sub_postal_code = parent::getValue($props, "sub_postal_code");
98
+ return $address;
99
+ }
100
+ }
app/api/Ctct/Components/Contacts/Contact.php ADDED
@@ -0,0 +1,245 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Ctct\Components\Contacts;
3
+
4
+ use Ctct\Components\Component;
5
+
6
+ /**
7
+ * Represents a single Contact in Constant Contact
8
+ *
9
+ * @package Components
10
+ * @subpackage Contacts
11
+ * @author Constant Contact
12
+ */
13
+ class Contact extends Component {
14
+ /**
15
+ * Unique identifier for the contact
16
+ * @var string
17
+ */
18
+ public $id;
19
+
20
+ /**
21
+ * Status of the contact, must be one of "ACTIVE", "UNCONFIRMED", "OPTOUT", "REMOVED", "NON_SUBSCRIBER", "VISITOR"
22
+ * @var string
23
+ */
24
+ public $status;
25
+
26
+ /**
27
+ * First name of the contact
28
+ * @var string
29
+ */
30
+ public $first_name;
31
+
32
+ /**
33
+ * Last name of the contact
34
+ * @var string
35
+ */
36
+ public $last_name;
37
+
38
+ /**
39
+ * Whether or not the contact is confirmed
40
+ * @var boolean
41
+ */
42
+ public $confirmed;
43
+
44
+ /**
45
+ * Contact source information
46
+ * @var string
47
+ */
48
+ public $source;
49
+
50
+ /**
51
+ * Array of email addresses associated with this contact
52
+ * @var EmailAddress[]
53
+ */
54
+ public $email_addresses = array();
55
+
56
+ /**
57
+ * The prefix name of the contact
58
+ * @var string
59
+ */
60
+ public $prefix_name;
61
+
62
+ /**
63
+ * The job title of the contact
64
+ * @var string
65
+ */
66
+ public $job_title;
67
+
68
+ /**
69
+ * Array of addresses associated with this contact
70
+ * @var Address[]
71
+ */
72
+ public $addresses = array();
73
+
74
+ /**
75
+ * Array of notes associated with this contact
76
+ * @var Note[]
77
+ */
78
+ public $notes = array();
79
+
80
+ /**
81
+ * Company name this contact works for
82
+ * @var string
83
+ */
84
+ public $company_name;
85
+
86
+ /**
87
+ * Contact's home phone number
88
+ * @var string
89
+ */
90
+ public $home_phone;
91
+
92
+ /**
93
+ * Contact's work phone number
94
+ * @var string
95
+ */
96
+ public $work_phone;
97
+
98
+ /**
99
+ * Contact's cell phone number
100
+ * @var string
101
+ */
102
+ public $cell_phone;
103
+
104
+ /**
105
+ * Contact's fax number
106
+ * @var string
107
+ */
108
+ public $fax;
109
+
110
+ /**
111
+ * Array of custom fields associated with this contact
112
+ * @var CustomField[]
113
+ */
114
+ public $custom_fields = array();
115
+
116
+ /**
117
+ * Array of contact lists this contact belongs to
118
+ * @var ContactList[]
119
+ */
120
+ public $lists = array();
121
+
122
+ /**
123
+ * Date the contact was created
124
+ * @var string
125
+ */
126
+ public $created_date;
127
+
128
+ /**
129
+ * Date the contact was last modified
130
+ * @var string
131
+ */
132
+ public $modified_date;
133
+
134
+ /**
135
+ * Contact source details
136
+ * @var string
137
+ */
138
+ public $source_details;
139
+
140
+ /**
141
+ * Factory method to create a Contact object from an array
142
+ * @param array $props - Associative array of initial properties to set
143
+ * @return Contact
144
+ */
145
+ public static function create(array $props) {
146
+ $contact = new Contact();
147
+ $contact->id = parent::getValue($props, "id");
148
+ $contact->status = parent::getValue($props, "status");
149
+ $contact->first_name = parent::getValue($props, "first_name");
150
+ $contact->last_name = parent::getValue($props, "last_name");
151
+ $contact->confirmed = parent::getValue($props, "confirmed");
152
+ $contact->source = parent::getValue($props, "source");
153
+
154
+ if (isset($props['email_addresses'])) {
155
+ foreach ($props['email_addresses'] as $email_address) {
156
+ $contact->email_addresses[] = EmailAddress::create($email_address);
157
+ }
158
+ }
159
+
160
+ $contact->prefix_name = parent::getValue($props, "prefix_name");
161
+ $contact->job_title = parent::getValue($props, "job_title");
162
+
163
+ if (isset($props['addresses'])) {
164
+ foreach ($props['addresses'] as $address) {
165
+ $contact->addresses[] = Address::create($address);
166
+ }
167
+ }
168
+
169
+ if (isset($props['notes'])) {
170
+ foreach ($props['notes'] as $note) {
171
+ $contact->notes[] = Note::create($note);
172
+ }
173
+ }
174
+
175
+ $contact->company_name = parent::getValue($props, "company_name");
176
+ $contact->home_phone = parent::getValue($props, "home_phone");
177
+ $contact->work_phone = parent::getValue($props, "work_phone");
178
+ $contact->cell_phone = parent::getValue($props, "cell_phone");
179
+ $contact->fax = parent::getValue($props, "fax");
180
+
181
+ if (isset($props['custom_fields'])) {
182
+ foreach ($props['custom_fields'] as $custom_field) {
183
+ $contact->custom_fields[] = CustomField::create($custom_field);
184
+ }
185
+ }
186
+
187
+ if (isset($props['lists'])) {
188
+ foreach ($props['lists'] as $contact_list) {
189
+ $contact->lists[] = ContactList::create($contact_list);
190
+ }
191
+ }
192
+
193
+ $contact->created_date = parent::getValue($props, "created_date");
194
+ $contact->modified_date = parent::getValue($props, "modified_date");
195
+
196
+ $contact->source_details = parent::getValue($props, "source_details");
197
+
198
+ return $contact;
199
+ }
200
+
201
+ /**
202
+ * Add a ContactList
203
+ * @param mixed $contactList - ContactList object or contact list id
204
+ */
205
+ public function addList($contactList) {
206
+ if (!$contactList instanceof ContactList) {
207
+ $contactList = new ContactList($contactList);
208
+ }
209
+
210
+ $this->lists[] = $contactList;
211
+ }
212
+
213
+ /**
214
+ * Add an EmailAddress
215
+ * @param mixed $emailAddress - EmailAddress object or email address
216
+ */
217
+ public function addEmail($emailAddress) {
218
+ if (!$emailAddress instanceof EmailAddress) {
219
+ $emailAddress = new EmailAddress($emailAddress);
220
+ }
221
+
222
+ $this->email_addresses[] = $emailAddress;
223
+ }
224
+
225
+ /**
226
+ * Add a custom field to the contact object
227
+ * @param CustomField $customField - custom field to add to the contact
228
+ */
229
+ public function addCustomField(CustomField $customField) {
230
+ $this->custom_fields[] = $customField;
231
+ }
232
+
233
+ /**
234
+ * Add an address
235
+ * @param Address $address - Address to add
236
+ */
237
+ public function addAddress(Address $address) {
238
+ $this->addresses[] = $address;
239
+ }
240
+
241
+ public function toJson() {
242
+ unset($this->last_update_date);
243
+ return json_encode($this);
244
+ }
245
+ }
app/api/Ctct/Components/Contacts/ContactList.php ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Ctct\Components\Contacts;
3
+
4
+ use Ctct\Components\Component;
5
+
6
+ /**
7
+ * Represents a single Contact List
8
+ *
9
+ * @package Components
10
+ * @subpackage Contacts
11
+ * @author Constant Contact
12
+ */
13
+ class ContactList extends Component {
14
+ /**
15
+ * Unique identifier of the contact list
16
+ * @var string
17
+ */
18
+ public $id;
19
+
20
+ /**
21
+ * Name of the contact list
22
+ * @var string
23
+ */
24
+ public $name;
25
+
26
+ /**
27
+ * Status of the contact list, must be one of "ACTIVE", "HIDDEN", "REMOVED"
28
+ * @var string
29
+ */
30
+ public $status;
31
+
32
+ /**
33
+ * The number of contacts in the list
34
+ * @var string
35
+ */
36
+ public $contact_count;
37
+
38
+ /**
39
+ * Date and time the list was created.
40
+ * @var string
41
+ */
42
+ public $created_date;
43
+
44
+ /**
45
+ * Date and time the list was last modified.
46
+ * @var string
47
+ */
48
+ public $modified_date;
49
+
50
+ public function __construct($list_id = null) {
51
+ if (!is_null($list_id)) {
52
+ $this->id = $list_id;
53
+ }
54
+
55
+ return $this;
56
+ }
57
+
58
+ /**
59
+ * Factory method to create a ContactList object from an array
60
+ * @param array $props - Associative array of initial properties to set
61
+ * @return ContactList
62
+ */
63
+ public static function create(array $props) {
64
+ $contact_list = new ContactList();
65
+ $contact_list->id = parent::getValue($props, "id");
66
+ $contact_list->name = parent::getValue($props, "name");
67
+ $contact_list->status = parent::getValue($props, "status");
68
+ $contact_list->contact_count = parent::getValue($props, "contact_count");
69
+ $contact_list->created_date = parent::getValue($props, "created_date");
70
+ $contact_list->modified_date = parent::getValue($props, "modified_date");
71
+ return $contact_list;
72
+ }
73
+
74
+ public function toJson() {
75
+ return json_encode($this);
76
+ }
77
+ }
app/api/Ctct/Components/Contacts/CustomField.php ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Ctct\Components\Contacts;
3
+
4
+ use Ctct\Components\Component;
5
+
6
+ /**
7
+ * Represents a single Custom Field for a Contact
8
+ *
9
+ * @package Components
10
+ * @subpackage Contacts
11
+ * @author Constant Contact
12
+ */
13
+ class CustomField extends Component {
14
+ /**
15
+ * Name of the custom field
16
+ * @var string
17
+ */
18
+ public $name;
19
+
20
+ /**
21
+ * Value of the custom field
22
+ * @var string
23
+ */
24
+ public $value;
25
+
26
+ /**
27
+ * Factory method to create a CustomField object from an array
28
+ * @param array $props - Associative array of initial properties to set
29
+ * @return CustomField
30
+ */
31
+ public static function create(array $props) {
32
+ $custom_field = new CustomField();
33
+ $custom_field->name = parent::getValue($props, "name");
34
+ $custom_field->value = parent::getValue($props, "value");
35
+ return $custom_field;
36
+ }
37
+ }
app/api/Ctct/Components/Contacts/EmailAddress.php ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Ctct\Components\Contacts;
3
+
4
+ use Ctct\Components\Component;
5
+
6
+ /**
7
+ * Represents a single EmailAddress of a Contact
8
+ *
9
+ * @package Components
10
+ * @subpackage Contacts
11
+ * @author Constant Contact
12
+ */
13
+ class EmailAddress extends Component {
14
+ /**
15
+ * Id of the email address
16
+ * @var string
17
+ */
18
+ public $id;
19
+
20
+ /**
21
+ * Status of the email address, must be one of "ACTIVE", "UNCONFIRMED", "OPTOUT", "REMOVED",
22
+ * "NON_SUBSCRIBER", "VISITOR"
23
+ * @var string
24
+ */
25
+ public $status;
26
+
27
+ /**
28
+ * Contact's confirmation status, must be one of "CONFIRMED", "NO_CONFIRMATION_REQUIRED", "UNCONFIRMED"
29
+ * @var string
30
+ */
31
+ public $confirm_status;
32
+
33
+ /**
34
+ * Contact's opt in source, must be one of "ACTION_BY_VISITOR", "ACTION_BY_OWNER"
35
+ * @var string
36
+ */
37
+ public $opt_in_source;
38
+
39
+ /**
40
+ * Contact's opt in date in ISO 8601 format
41
+ * @var string
42
+ */
43
+ public $opt_in_date;
44
+
45
+ /**
46
+ * Contact's opt out date in ISO 8601 format
47
+ * @var string
48
+ */
49
+ public $opt_out_date;
50
+
51
+ /**
52
+ * Email address associated with the contact
53
+ * @var string
54
+ */
55
+ public $email_address;
56
+
57
+ public function __construct($email_address = null) {
58
+ if (!is_null($email_address)) {
59
+ $this->email_address = $email_address;
60
+ }
61
+
62
+ return $this;
63
+ }
64
+
65
+ /**
66
+ * Factory method to create an EmailAddress object from an array
67
+ * @param array $props - Associative array of initial properties to set
68
+ * @return EmailAddress
69
+ */
70
+ public static function create(array $props) {
71
+ $email_address = new EmailAddress();
72
+ $email_address->id = parent::getValue($props, "id");
73
+ $email_address->status = parent::getValue($props, "status");
74
+ $email_address->confirm_status = parent::getValue($props, "confirm_status");
75
+ $email_address->opt_in_source = parent::getValue($props, "opt_in_source");
76
+ $email_address->opt_in_date = parent::getValue($props, "opt_in_date");
77
+ $email_address->opt_out_date = parent::getValue($props, "opt_out_date");
78
+ $email_address->email_address = parent::getValue($props, "email_address");
79
+ return $email_address;
80
+ }
81
+ }
app/api/Ctct/Components/Contacts/Note.php ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Ctct\Components\Contacts;
3
+
4
+ use Ctct\Components\Component;
5
+
6
+ /**
7
+ * Represents a Contact Note
8
+ *
9
+ * @package Components
10
+ * @subpackage Contacts
11
+ * @author Constant Contact
12
+ */
13
+ class Note extends Component {
14
+ /**
15
+ * Id of the note
16
+ * @var string
17
+ */
18
+ public $id;
19
+
20
+ /**
21
+ * Content of the note
22
+ * @var string
23
+ */
24
+ public $note;
25
+
26
+ /**
27
+ * Date the note was created
28
+ * @var string
29
+ */
30
+ public $created_date;
31
+
32
+ /**
33
+ * Factory method to create a Note object from an array
34
+ * @param array $props - Associative array of initial properties to set
35
+ * @return Note
36
+ */
37
+ public static function create(array $props) {
38
+ $note = new Note();
39
+ $note->id = parent::getValue($props, "id");
40
+ $note->note = parent::getValue($props, "note");
41
+ $note->created_date = parent::getValue($props, "created_date");
42
+ return $note;
43
+ }
44
+ }
app/api/Ctct/Components/EmailMarketing/Campaign.php ADDED
@@ -0,0 +1,321 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Ctct\Components\EmailMarketing;
3
+
4
+ use Ctct\Components\Component;
5
+ use Ctct\Components\Contacts\ContactList;
6
+ use Ctct\Components\Tracking\TrackingSummary;
7
+ use Ctct\Exceptions\IllegalArgumentException;
8
+ use Ctct\Util\Config;
9
+
10
+ /**
11
+ * Represents a single Campaign in Constant Contact
12
+ *
13
+ * @package Components
14
+ * @subpackage EmailMarketing
15
+ * @author Constant Contact
16
+ */
17
+ class Campaign extends Component {
18
+ /**
19
+ * Unique identifier for the email campaign
20
+ * @var string
21
+ */
22
+ public $id;
23
+
24
+ /**
25
+ * Name of the email campaign; each email campaign name must be unique within a user's account
26
+ * @var string
27
+ */
28
+ public $name;
29
+
30
+ /**
31
+ * The Subject Line for the email campaign
32
+ * @var string
33
+ */
34
+ public $subject;
35
+
36
+ /**
37
+ * Current status of the email campaign
38
+ * @var string
39
+ */
40
+ public $status;
41
+
42
+ /**
43
+ * Name displayed in the From field to indicate whom the email is from
44
+ * @var string
45
+ */
46
+ public $from_name;
47
+
48
+ /**
49
+ * The email address the email campaign originated from, this must be a verified email address for the account owner
50
+ * @var string
51
+ */
52
+ public $from_email;
53
+
54
+ /**
55
+ * The reply-to email address for the email campaign, this must be a verified email address for the account owner
56
+ * @var string
57
+ */
58
+ public $reply_to_email;
59
+
60
+ /**
61
+ * The template used to create the email campaign
62
+ * @var string
63
+ */
64
+ public $template_type;
65
+
66
+ /**
67
+ * Date the email campaign was last sent to contacts, in ISO-8601 format
68
+ * @var string
69
+ */
70
+ public $created_date;
71
+
72
+ /**
73
+ * Date the email campaign was last modified, in ISO-8601 format
74
+ * @var string
75
+ */
76
+ public $modified_date;
77
+
78
+ /**
79
+ * Date the email campaign was last run, in ISO-8601 format
80
+ * @var string
81
+ */
82
+ public $last_run_date;
83
+
84
+ /**
85
+ * Date the email campaign is next scheduled to run and be sent to contacts, in ISO-8601 format
86
+ * @var string
87
+ */
88
+ public $next_run_date;
89
+
90
+ /**
91
+ * If true, displays permission_reminder_text at top of email message
92
+ * @var boolean
93
+ */
94
+ public $is_permission_reminder_enabled;
95
+
96
+ /**
97
+ * Text to be displayed at the top of the email if is_permission_reminder_enabled is true
98
+ * @var string
99
+ */
100
+ public $permission_reminder_text;
101
+
102
+ /**
103
+ * If true, displays the text and link specified in permission_reminder_text to view web page
104
+ * version of email message
105
+ * @var string
106
+ */
107
+ public $is_view_as_webpage_enabled;
108
+
109
+ /**
110
+ * Text to be displayed if is_view_as_webpage_enabled is true
111
+ * @var string
112
+ */
113
+ public $view_as_web_page_text;
114
+
115
+ /**
116
+ * Text that will be displayed as the link if is_view_as_webpage_enabled is true
117
+ * @var string
118
+ */
119
+ public $view_as_web_page_link_text;
120
+
121
+ /**
122
+ * The salutation used in the email message (e.g. Dear)
123
+ * @var string
124
+ */
125
+ public $greeting_salutations;
126
+
127
+ /**
128
+ * This is the personalized content for each contact that will be used in the greeting
129
+ * @var string
130
+ */
131
+ public $greeting_name;
132
+
133
+ /**
134
+ * Specifies the greeting text used if not using greeting_name and greeting_salutations
135
+ * @var string
136
+ */
137
+ public $greeting_string;
138
+
139
+ /**
140
+ * Defines the content of the email campaign message footer
141
+ * @var MessageFooter
142
+ */
143
+ public $message_footer;
144
+
145
+ /**
146
+ * Campaign Tracking summary data for this campaign
147
+ * @var TrackingSummary
148
+ */
149
+ public $tracking_summary;
150
+
151
+ /**
152
+ * The full HTML or XHTML content of the email campaign
153
+ * @var string
154
+ */
155
+ public $email_content;
156
+
157
+ /**
158
+ * Specifies the email campaign message format, valid values: HTML, XHTML
159
+ * @var string
160
+ */
161
+ public $email_content_format;
162
+
163
+ /**
164
+ * Style sheet used in the email
165
+ * @var string
166
+ */
167
+ public $style_sheet;
168
+
169
+ /**
170
+ * The content for the text-only version of the email campaign which is viewed by recipients
171
+ * whose email client does not accept HTML email
172
+ * @var string
173
+ */
174
+ public $text_content;
175
+
176
+ /**
177
+ * Unique IDs of the contact lists the email campaign message is sent to
178
+ * @var array
179
+ */
180
+ public $sent_to_contact_lists = array();
181
+
182
+ /**
183
+ * Tracking summary data for this email campaign
184
+ * @var array
185
+ */
186
+ public $click_through_details = array();
187
+
188
+ /**
189
+ * URL of the permalink for this email campaign if it exists
190
+ * @var string
191
+ */
192
+ public $permalink_url;
193
+
194
+ /**
195
+ * Factory method to create a Campaign object from an array
196
+ * @param array $props - associative array of initial properties to set
197
+ * @return Campaign
198
+ */
199
+ public static function create(array $props) {
200
+ $campaign = new Campaign();
201
+ $campaign->id = parent::getValue($props, "id");
202
+ $campaign->name = parent::getValue($props, "name");
203
+ $campaign->subject = parent::getValue($props, "subject");
204
+ $campaign->from_name = parent::getValue($props, "from_name");
205
+ $campaign->from_email = parent::getValue($props, "from_email");
206
+ $campaign->reply_to_email = parent::getValue($props, "reply_to_email");
207
+ $campaign->template_type = parent::getValue($props, "template_type");
208
+ $campaign->created_date = parent::getValue($props, "created_date");
209
+ $campaign->modified_date = parent::getValue($props, "modified_date");
210
+ $campaign->last_run_date = parent::getValue($props, "last_run_date");
211
+ $campaign->next_run_date = parent::getValue($props, "next_run_date");
212
+ $campaign->status = parent::getValue($props, "status");
213
+ $campaign->is_permission_reminder_enabled = parent::getValue($props, "is_permission_reminder_enabled");
214
+ $campaign->permission_reminder_text = parent::getValue($props, "permission_reminder_text");
215
+ $campaign->is_view_as_webpage_enabled = parent::getValue($props, "is_view_as_webpage_enabled");
216
+ $campaign->view_as_web_page_text = parent::getValue($props, "view_as_web_page_text");
217
+ $campaign->view_as_web_page_link_text = parent::getValue($props, "view_as_web_page_link_text");
218
+ $campaign->greeting_salutations = parent::getValue($props, "greeting_salutations");
219
+ $campaign->greeting_name = parent::getValue($props, "greeting_name");
220
+ $campaign->greeting_string = parent::getValue($props, "greeting_string");
221
+
222
+ if (array_key_exists("message_footer", $props)) {
223
+ $campaign->message_footer = MessageFooter::create($props['message_footer']);
224
+ }
225
+
226
+ if (array_key_exists("tracking_summary", $props)) {
227
+ $campaign->tracking_summary = TrackingSummary::create($props['tracking_summary']);
228
+ }
229
+
230
+ $campaign->email_content = parent::getValue($props, "email_content");
231
+ $campaign->email_content_format = parent::getValue($props, "email_content_format");
232
+ $campaign->style_sheet = parent::getValue($props, "style_sheet");
233
+ $campaign->text_content = parent::getValue($props, "text_content");
234
+ $campaign->permalink_url = parent::getValue($props, "permalink_url");
235
+
236
+ if (array_key_exists('sent_to_contact_lists', $props)) {
237
+ foreach ($props['sent_to_contact_lists'] as $sent_to_contact_list) {
238
+ $campaign->sent_to_contact_lists[] = ContactList::create($sent_to_contact_list);
239
+ }
240
+ }
241
+
242
+ if (array_key_exists('click_through_details', $props)) {
243
+ foreach ($props['click_through_details'] as $click_through_details) {
244
+ $campaign->click_through_details[] = ClickThroughDetails::create($click_through_details);
245
+ }
246
+ }
247
+
248
+ return $campaign;
249
+ }
250
+
251
+ /**
252
+ * Factory method to create a Campaign object from an array
253
+ * @param array $props - associative array of initial properties to set
254
+ * @return Campaign
255
+ */
256
+ public static function createSummary(array $props) {
257
+ $campaign = new Campaign();
258
+ $campaign->id = parent::getValue($props, "id");
259
+ $campaign->name = parent::getValue($props, "name");
260
+ $campaign->status = parent::getValue($props, "status");
261
+ $campaign->modified_date = parent::getValue($props, "modified_date");
262
+
263
+ // remove unused fields
264
+ foreach ($campaign as $key => $value) {
265
+ if ($value == null) {
266
+ unset($campaign->$key);
267
+ }
268
+ }
269
+
270
+ return $campaign;
271
+ }
272
+
273
+ /**
274
+ * Add a contact list to set of lists associated with this email
275
+ * @param mixed $contact_list - Contact list id, or ContactList object
276
+ * @throws IllegalArgumentException
277
+ */
278
+ public function addList($contact_list) {
279
+ if ($contact_list instanceof ContactList) {
280
+ $list = $contact_list;
281
+ } elseif (is_numeric($contact_list)) {
282
+ $list = new ContactList($contact_list);
283
+ } else {
284
+ throw new IllegalArgumentException(sprintf(Config::get('errors.id_or_object'), 'ContactList'));
285
+ }
286
+
287
+ $this->sent_to_contact_lists[] = $list;
288
+ }
289
+
290
+ /**
291
+ * Create json used for a POST/PUT request, also handles removing attributes that will cause errors if sent
292
+ * @return string
293
+ */
294
+ public function toJson() {
295
+ $campaign = clone $this;
296
+ unset($campaign->id);
297
+ unset($campaign->created_date);
298
+ unset($campaign->last_run_date);
299
+ unset($campaign->next_run_date);
300
+ unset($campaign->tracking_summary);
301
+ unset($campaign->click_through_details);
302
+
303
+ if (is_null($campaign->message_footer)) {
304
+ unset($campaign->message_footer);
305
+ }
306
+
307
+ if (empty($campaign->sent_to_contact_lists)) {
308
+ unset($campaign->sent_to_contact_lists);
309
+ } else {
310
+
311
+ // remove sent_to_contact_lists fields that cause errors
312
+ foreach ($campaign->sent_to_contact_lists as $list) {
313
+ unset($list->name);
314
+ unset($list->contact_count);
315
+ unset($list->status);
316
+ }
317
+ }
318
+
319
+ return json_encode($campaign);
320
+ }
321
+ }
app/api/Ctct/Components/EmailMarketing/CampaignPreview.php ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Ctct\Components\EmailMarketing;
3
+
4
+ use Ctct\Components\Component;
5
+
6
+ class CampaignPreview extends Component {
7
+ /**
8
+ * Email address set as the from email
9
+ * @var String
10
+ */
11
+ public $fromEmail;
12
+
13
+ /**
14
+ * Email address set as the reply-to email
15
+ * @var String
16
+ */
17
+ public $replyToEmail;
18
+
19
+ /**
20
+ * Full HTML content of the campaign
21
+ * @var String
22
+ */
23
+ public $htmlContent;
24
+
25
+ /**
26
+ * Text version content of the campaign
27
+ * @var
28
+ */
29
+ public $textContent;
30
+
31
+ /**
32
+ * Subject of the email
33
+ * @var String
34
+ */
35
+ public $subject;
36
+
37
+ /**
38
+ * Factory method to create a CampaignPreview object from an array
39
+ * @param array $props - associative array of initial properties to set
40
+ * @return CampaignPreview
41
+ */
42
+ public static function create(array $props) {
43
+ $preview = new CampaignPreview();
44
+ $preview->fromEmail = parent::getValue($props, "from_email");
45
+ $preview->replyToEmail = parent::getValue($props, "reply_to_email");
46
+ $preview->htmlContent = parent::getValue($props, "preview_email_content");
47
+ $preview->textContent = parent::getValue($props, "preview_text_content");
48
+ $preview->subject = parent::getValue($props, "subject");
49
+ return $preview;
50
+ }
51
+ }
app/api/Ctct/Components/EmailMarketing/ClickThroughDetails.php ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Ctct\Components\EmailMarketing;
3
+
4
+ use Ctct\Components\Component;
5
+
6
+ /**
7
+ * Represents a click through detail
8
+ *
9
+ * @package EmailMarketing
10
+ * @subpackage Campaigns
11
+ * @author Constant Contact
12
+ */
13
+ class ClickThroughDetails extends Component {
14
+ /**
15
+ * the actual url that was clicked on
16
+ * @var string
17
+ */
18
+ public $url;
19
+
20
+ /**
21
+ * url unique identifier
22
+ * @var string
23
+ */
24
+ public $url_uid;
25
+
26
+ /**
27
+ * number of times the url was clicked on
28
+ * @var int
29
+ */
30
+ public $click_count;
31
+
32
+ /**
33
+ * Factory method to create a ClickThroughDetails object from an array
34
+ * @param array $props - associative array of initial properties to set
35
+ * @return ClickThroughDetails
36
+ */
37
+ public static function create(array $props) {
38
+ $click_through_details = new ClickThroughDetails();
39
+ $click_through_details->url = parent::getValue($props, "url");
40
+ $click_through_details->url_uid = parent::getValue($props, "url_uid");
41
+ $click_through_details->click_count = parent::getValue($props, "click_count");
42
+ return $click_through_details;
43
+ }
44
+ }
app/api/Ctct/Components/EmailMarketing/MessageFooter.php ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Ctct\Components\EmailMarketing;
3
+
4
+ use Ctct\Components\Component;
5
+
6
+ /**
7
+ * Represents a click through detail
8
+ *
9
+ * @package EmailMarketing
10
+ * @subpackage Campaigns
11
+ * @author Constant Contact
12
+ */
13
+ class MessageFooter extends Component {
14
+ public $city;
15
+ public $state;
16
+ public $country;
17
+ public $organization_name;
18
+ public $address_line_1;
19
+ public $address_line_2;
20
+ public $address_line_3;
21
+ public $international_state;
22
+ public $postal_code;
23
+ public $include_forward_email;
24
+ public $forward_email_link_text;
25
+ public $include_subscribe_link;
26
+ public $subscribe_link_text;
27
+
28
+ /**
29
+ * Factory method to create a MessageFooter object from an array
30
+ * @param array $props - associative array of initial properties to set
31
+ * @return MessageFooter
32
+ */
33
+ public static function create(array $props) {
34
+ $message_footer = new MessageFooter();
35
+ $message_footer->city = parent::getValue($props, "city");
36
+ $message_footer->state = parent::getValue($props, "state");
37
+ $message_footer->country = parent::getValue($props, "country");
38
+ $message_footer->organization_name = parent::getValue($props, "organization_name");
39
+ $message_footer->address_line_1 = parent::getValue($props, "address_line_1");
40
+ $message_footer->address_line_2 = parent::getValue($props, "address_line_2");
41
+ $message_footer->address_line_3 = parent::getValue($props, "address_line_3");
42
+ $message_footer->international_state = parent::getValue($props, "international_state");
43
+ $message_footer->postal_code = parent::getValue($props, "postal_code");
44
+ $message_footer->include_forward_email = parent::getValue($props, "include_forward_email");
45
+ $message_footer->forward_email_link_text = parent::getValue($props, "forward_email_link_text");
46
+ $message_footer->include_subscribe_link = parent::getValue($props, "include_subscribe_link");
47
+ $message_footer->subscribe_link_text = parent::getValue($props, "subscribe_link_text");
48
+
49
+ return $message_footer;
50
+ }
51
+ }
app/api/Ctct/Components/EmailMarketing/Schedule.php ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Ctct\Components\EmailMarketing;
3
+
4
+ use Ctct\Components\Component;
5
+
6
+ /**
7
+ * Represents a campaign Schedule in Constant Contact
8
+ *
9
+ * @package Components
10
+ * @subpackage EmailMarketing
11
+ * @author Constant Contact
12
+ */
13
+ class Schedule extends Component {
14
+ /**
15
+ * unique id of the schedule
16
+ * @var string
17
+ */
18
+ public $id;
19
+
20
+ /**
21
+ * The scheduled start date/time in ISO 8601 format
22
+ * @var string
23
+ */
24
+ public $scheduled_date;
25
+
26
+
27
+ /**
28
+ * Factory method to create a Schedule object from an array
29
+ * @param array $props - associative array of initial properties to set
30
+ * @return Schedule
31
+ */
32
+ public static function create(array $props) {
33
+ $schedule = new Schedule();
34
+ $schedule->id = parent::getValue($props, "id");
35
+ $schedule->scheduled_date = parent::getValue($props, "scheduled_date");
36
+ return $schedule;
37
+ }
38
+
39
+ /**
40
+ * Create json used for a POST/PUT request, also handles removing attributes that will cause errors if sent
41
+ * @return string
42
+ */
43
+ public function toJson() {
44
+ $schedule = clone $this;
45
+ unset($schedule->id);
46
+ return json_encode($schedule);
47
+ }
48
+ }
app/api/Ctct/Components/EmailMarketing/TestSend.php ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Ctct\Components\EmailMarketing;
3
+
4
+ use Ctct\Components\Component;
5
+
6
+ /**
7
+ * Represents a campaign Test Send in Constant Contact
8
+ *
9
+ * @package Components
10
+ * @subpackage EmailMarketing
11
+ * @author Constant Contact
12
+ */
13
+ class TestSend extends Component {
14
+ /**
15
+ * Format of the email to send (HTML, TEXT, HTML_AND_TEXT)
16
+ * @var string
17
+ */
18
+ public $format;
19
+
20
+ /**
21
+ * Personal message to send along with the test send
22
+ * @var
23
+ */
24
+ public $personal_message;
25
+
26
+ /**
27
+ * Array of email addresses to send the test send to
28
+ * @var array
29
+ */
30
+ public $email_addresses = array();
31
+
32
+ /**
33
+ * Factory method to create a TestSend object from an array
34
+ * @param array $props - associative array of initial properties to set
35
+ * @return TestSend
36
+ */
37
+ public static function create(array $props) {
38
+ $test_send = new TestSend();
39
+ $test_send->format = parent::getValue($props, "format");
40
+ $test_send->personal_message = parent::getValue($props, "personal_message");
41
+
42
+ foreach ($props['email_addresses'] as $email_address) {
43
+ $test_send->email_addresses[] = $email_address;
44
+ }
45
+
46
+ return $test_send;
47
+ }
48
+
49
+ /**
50
+ * Add an email address to the set of addresses to send the test send too
51
+ * @param string $email_address
52
+ */
53
+ public function addEmail($email_address) {
54
+ $this->email_addresses[] = $email_address;
55
+ }
56
+
57
+ /**
58
+ * Create json used for a POST/PUT request, also handles removing attributes that will cause errors if sent
59
+ * @return string
60
+ */
61
+ public function toJson() {
62
+ $testSend = clone $this;
63
+ if ($testSend->personal_message == null) {
64
+ unset($testSend->personal_message);
65
+ }
66
+ return json_encode($testSend);
67
+ }
68
+ }
app/api/Ctct/Components/EventSpot/Address.php ADDED
@@ -0,0 +1,103 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Ctct\Components\EventSpot;
3
+
4
+ use Ctct\Components\Component;
5
+
6
+ /**
7
+ * Represents a single Address of a Payment
8
+ *
9
+ * @package Components
10
+ * @subpackage EventSpot
11
+ * @author Constant Contact
12
+ */
13
+ class Address extends Component
14
+ {
15
+ /**
16
+ * City info for this address
17
+ * @var string
18
+ */
19
+ public $city;
20
+
21
+ /**
22
+ * Country of the event location
23
+ * @var string (128)
24
+ */
25
+ public $country;
26
+
27
+ /**
28
+ * Standard 2 letter ISO 3166-1 code of the country associated with the event address
29
+ * @var string (2)
30
+ */
31
+ public $country_code;
32
+
33
+ /**
34
+ * Latitude coordinates of the event location
35
+ * @var float
36
+ */
37
+ public $latitude;
38
+
39
+ /**
40
+ * Line 1 of the address
41
+ * @var string
42
+ */
43
+ public $line1;
44
+
45
+ /**
46
+ * Line 2 of the address
47
+ * @var string
48
+ */
49
+ public $line2;
50
+
51
+ /**
52
+ * Line 3 of the address
53
+ * @var string
54
+ */
55
+ public $line3;
56
+
57
+ /**
58
+ * Longitude coordinates of the event location
59
+ * @var float
60
+ */
61
+ public $longitude;
62
+
63
+ /**
64
+ * Postal ZIP code for the event
65
+ * @var string (25)
66
+ */
67
+ public $postal_code;
68
+
69
+ /**
70
+ * The state for this address (non-US/Canada)
71
+ * @var string (50)
72
+ */
73
+ public $state;
74
+
75
+ /**
76
+ * The state code for this address
77
+ * @var string (50)
78
+ */
79
+ public $state_code;
80
+
81
+
82
+ /**
83
+ * Factory method to create an Address object from an array
84
+ * @param array $props - Associative array of initial properties to set
85
+ * @return Address
86
+ */
87
+ public static function create(array $props)
88
+ {
89
+ $address = new Address();
90
+ $address->id = parent::getValue($props, "id");
91
+ $address->line1 = parent::getValue($props, "line1");
92
+ $address->line2 = parent::getValue($props, "line2");
93
+ $address->line3 = parent::getValue($props, "line3");
94
+ $address->city = parent::getValue($props, "city");
95
+ $address->address_type = parent::getValue($props, "address_type");
96
+ $address->state_code = parent::getValue($props, "state_code");
97
+ $address->state = parent::getValue($props, "state");
98
+ $address->country_code = parent::getValue($props, "country_code");
99
+ $address->postal_code = parent::getValue($props, "postal_code");
100
+ $address->sub_postal_code = parent::getValue($props, "sub_postal_code");
101
+ return $address;
102
+ }
103
+ }
app/api/Ctct/Components/EventSpot/Contact.php ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Ctct\Components\EventSpot;
3
+
4
+ use Ctct\Components\Component;
5
+
6
+ /**
7
+ * Represents the event Contact
8
+ *
9
+ * @package Components
10
+ * @subpackage EventSpot
11
+ * @author Katz Web Services, Inc.
12
+ */
13
+ class Contact extends Component
14
+ {
15
+ /**
16
+ * @var string
17
+ */
18
+ public $email_address;
19
+
20
+ /**
21
+ * @var string (100)
22
+ */
23
+ public $name;
24
+
25
+ /**
26
+ * @var string (100)
27
+ */
28
+ public $organization_name;
29
+
30
+ /**
31
+ * @var string
32
+ */
33
+ public $phone_number;
34
+
35
+ /**
36
+ * Factory method to create a Contact object from an array
37
+ * @param array $props - Associative array of initial properties to set
38
+ * @return Contact
39
+ */
40
+ public static function create(array $props)
41
+ {
42
+ $guest = new Contact();
43
+ $guest->email_address = parent::getValue($props, "email_address");
44
+ $guest->name = parent::getValue($props, "name");
45
+ $guest->organization_name = parent::getValue($props, "organization_name");
46
+ $guest->phone_number = parent::getValue($props, "phone_number");
47
+
48
+ return $guest;
49
+ }
50
+ }
app/api/Ctct/Components/EventSpot/EventFee.php ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Ctct\Components\EventSpot;
3
+
4
+ use Ctct\Components\Component;
5
+
6
+ /**
7
+ * Represents a single Contact List
8
+ *
9
+ * @package Components
10
+ * @subpackage Contacts
11
+ * @author Katz Web Services, Inc.
12
+ */
13
+ class EventFee extends Component
14
+ {
15
+ /**
16
+ * Unique identifier of the contact list
17
+ * @var string (50) Unique ID for that fee
18
+ */
19
+ public $id;
20
+
21
+ /**
22
+ * Fee for registrations that occur prior to the event's early_fee_date
23
+ * @var string (100) Fee description displayed to event registrants, each label must be unique
24
+ */
25
+ public $label;
26
+
27
+ /**
28
+ * Specifies who the fee applies to:
29
+ * BOTH - Fee applies to Registrants and Guests
30
+ * REGISTRANTS - Fee applies to registrants only
31
+ * GUESTS - Fee applies to guests only
32
+ * @var integer
33
+ */
34
+ public $fee_scope;
35
+
36
+ /**
37
+ * The fee amount
38
+ * @var float
39
+ */
40
+ public $fee;
41
+
42
+ /**
43
+ * The event title, visible to registrants
44
+ * @var string (100)
45
+ */
46
+ public $early_fee;
47
+
48
+ /**
49
+ * Fee for registrations that occur after the event's late_fee_date
50
+ * @var float
51
+ */
52
+ public $late_fee;
53
+
54
+ /**
55
+ * If true, fee is not displayed on registration page, and is available only to registrants who have a special promocode linked to this fee.
56
+ * @see RegistrantPromoCode
57
+ * @var bool
58
+ */
59
+ public $has_restricted_access = false;
60
+
61
+ /**
62
+ * Factory method to create a EventList object from an array
63
+ * @param array $props - Associative array of initial properties to set
64
+ * @return EventFee
65
+ */
66
+ public static function create(array $props)
67
+ {
68
+ $event_fee = new EventFee( $props );
69
+ $event_fee->id = parent::getValue($props, "id");
70
+ $event_fee->label = parent::getValue($props, "label");
71
+ $event_fee->fee = parent::getValue($props, "fee");
72
+ $event_fee->fee_scope = parent::getValue($props, "fee_scope");
73
+ $event_fee->early_fee = parent::getValue($props, "early_fee");
74
+ $event_fee->late_fee = parent::getValue($props, "late_fee");
75
+ $event_fee->has_restricted_access = parent::getValue($props, "has_restricted_access");
76
+
77
+ return $event_fee;
78
+ }
79
+
80
+ public function toJson()
81
+ {
82
+ return json_encode($this);
83
+ }
84
+ }
app/api/Ctct/Components/EventSpot/EventSpot.php ADDED
@@ -0,0 +1,366 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Ctct\Components\EventSpot;
3
+
4
+ use Ctct\Components\Component;
5
+
6
+ /**
7
+ * Represents a single Event in Constant Contact
8
+ *
9
+ * @package Components
10
+ * @subpackage Events
11
+ * @author Katz Web Services, Inc.
12
+ */
13
+ class EventSpot extends Component
14
+ {
15
+ /**
16
+ * Unique ID of the event
17
+ * @var string (26)
18
+ */
19
+ public $id;
20
+
21
+ /**
22
+ * Date event was published or announced, in ISO-8601 format
23
+ * @var string
24
+ */
25
+ public $active_date;
26
+
27
+ /**
28
+ * Address specifying the event location, used to determine event location on map if is_map_displayed set to true.
29
+ * @var Address
30
+ */
31
+ public $address;
32
+
33
+ /**
34
+ * Set to true allows registrants to view others who have registered for the event, default = false
35
+ * @var boolean
36
+ */
37
+ public $are_registrants_public = false;
38
+
39
+ /**
40
+ * Date the event was cancelled in ISO-8601 format
41
+ * @var string
42
+ */
43
+ public $cancelled_date;
44
+
45
+ /**
46
+ * The event host's contact information
47
+ * @var Contact
48
+ */
49
+ public $contact;
50
+
51
+ /**
52
+ * Date the event was created, in ISO-8601 format
53
+ * @var string
54
+ */
55
+ public $created_date;
56
+
57
+ /**
58
+ * Currency that the account will be paid in; although this is not a required field, it has a default value of USD.
59
+ * Valid values are: USD, CAD, AUD, CHF, CZK, DKK, EUR, GBP, HKD, HUF, ILS, JPY, MXN, NOK, NZD, PHP, PLN, SEK, SGD, THB, TWD
60
+ * @var string
61
+ */
62
+ public $currency_type;
63
+
64
+ /**
65
+ * Date the event was deleted, in ISO-8601 format
66
+ * @var string
67
+ */
68
+ public $deleted_date;
69
+
70
+ /**
71
+ * Provide a brief description of the event that will be visible on the event registration form and landing page
72
+ * @var string (350)
73
+ */
74
+ public $description;
75
+
76
+ /**
77
+ * The event end date, in ISO-8601 format
78
+ * @var string
79
+ */
80
+ public $end_date;
81
+
82
+ /**
83
+ * URL that points to the detailed description of that event, same as a GET on a specific event.
84
+ * @var string
85
+ */
86
+ public $event_detail_url;
87
+
88
+ /**
89
+ * Enter the Google analytics key if being used to track the event registration homepage
90
+ * @var string (20)
91
+ */
92
+ public $google_analytics_key;
93
+
94
+ /**
95
+ * Google merchant id to which payments are made; Google Checkout is not supported for new events, only valid on events created prior to October 2013.
96
+ * @var string (20)
97
+ */
98
+ public $google_merchant_id;
99
+
100
+ /**
101
+ * Set to true to display the event on the account's calendar; Default = true
102
+ * @var boolean
103
+ */
104
+ public $is_calendar_displayed;
105
+
106
+ /**
107
+ * Set to true to enable registrant check-in, and indicate that the registrant attended the event; default = false
108
+ * @var boolean
109
+ */
110
+ public $is_checkin_available;
111
+
112
+ /**
113
+ * Indicates if the event home/landing page is displayed for the event; set to true only if a landing page has been created for the event; default = false
114
+ * @var boolean
115
+ */
116
+ public $is_home_page_displayed;
117
+
118
+ /**
119
+ * Set to true to publish the event in external event directories such as SocialVents and EventsInAmerica; default = false
120
+ * @var boolean
121
+ */
122
+ public $is_listed_in_external_directory;
123
+
124
+ /**
125
+ * For future usage, Default = true
126
+ * @var boolean
127
+ */
128
+ public $is_map_displayed;
129
+
130
+ /**
131
+ * Set to true if this is an online event; default = false
132
+ * @var boolean
133
+ */
134
+ public $is_virtual_event;
135
+
136
+ /**
137
+ * Name of the venue or location at which the event is being held
138
+ * @var string (50)
139
+ */
140
+ public $location;
141
+
142
+ /**
143
+ * Specify keywords to improve search engine optimization (SEO) for the event; use commas to separate multiple keywords
144
+ * @var string (100)
145
+ */
146
+ public $meta_data_tags;
147
+
148
+ /**
149
+ * The event filename - not visible to registrants
150
+ * @var string (100)
151
+ */
152
+ public $name;
153
+
154
+ /**
155
+ * Define whether or not event notifications are sent to the contact email_address, and which notifications.
156
+ * @var NotificationOption
157
+ */
158
+ public $notification_options;
159
+
160
+ /**
161
+ * Online meeting details, REQUIRED if is_virtual_event is set to true
162
+ * @var OnlineMeeting
163
+ */
164
+ public $online_meeting;
165
+
166
+ /**
167
+ * Name to which registrants paying by check must make checks payable to; REQUIRED if 'CHECK' is selected as a payment option
168
+ * @var string (128)
169
+ */
170
+ public $payable_to;
171
+
172
+ /**
173
+ * Address to which checks will be sent. REQUIRED if CHECK is selected as a payment option
174
+ * @var Address
175
+ */
176
+ public $payment_address;
177
+
178
+ /**
179
+ * Specifies the payment options available to registrants. Multiple types allowed:
180
+ * PAYPAL
181
+ * GOOGLE_CHECKOUT - Not supported for new events as of October 2013
182
+ * CHECK - if selected, payment_address and payable_to are REQUIRED
183
+ * DOOR - payment is accepted at the door
184
+ * @var array
185
+ */
186
+ public $payment_options;
187
+
188
+ /**
189
+ * Email address linked to PayPal account to which payments will be made. REQUIRED if 'PAYPAL' is selected as a payment option
190
+ * @var string (128)
191
+ */
192
+ public $paypal_account_email;
193
+
194
+ /**
195
+ * For events that have a homepage configured (via the product GUI), the registration_url points to the event homepage, otherwise it points to the event registration page.
196
+ * @var string (250)
197
+ */
198
+ public $registration_url;
199
+
200
+ /**
201
+ * The event start date, in ISO-8601 format
202
+ * @var string
203
+ */
204
+ public $start_date;
205
+
206
+ /**
207
+ * The event status, valid values are:
208
+ * DRAFT
209
+ * ACTIVE - Event is published and publicly accessible
210
+ * COMPLETE - Event has occurred and is complete
211
+ * CANCELLED - Event is no long publicly accessible
212
+ * DELETED
213
+ * When an event is published, status transitions from DRAFT to ACTIVE.
214
+ * When an event is cancelled, status transitions from ACTIVE to CANCELLED.
215
+ * @var string
216
+ */
217
+ public $status;
218
+
219
+ /**
220
+ * The theme_name defines the layout and style (including background and color) for the event invitation, home page, and Registration form, see Event Themes for a list of all available themes; default = Default
221
+ * @var string
222
+ */
223
+ public $theme_name;
224
+
225
+ /**
226
+ * Specify additional text to help describe the event time zone
227
+ * @var string (80)
228
+ */
229
+ public $time_zone_description;
230
+
231
+ /**
232
+ * Time zone in which the event occurs, to see time_zone_id values go here.
233
+ * @var string (40)
234
+ */
235
+ public $time_zone_id;
236
+
237
+ /**
238
+ * The event title, visible to registrants
239
+ * @var string (100)
240
+ */
241
+ public $title;
242
+
243
+ /**
244
+ * Number of event registrants
245
+ * @var integer
246
+ */
247
+ public $total_registered_count;
248
+
249
+ /**
250
+ * Use these settings to define the information displayed on the Event registration page
251
+ * @var array {
252
+ * @type string $early_fee_date Date on which early fees end, in ISO-8601 format
253
+ * @type string $guest_display_label (50) Default = Guest(s); How guests are referred to on the registration form; use your own, or one of the following suggestions are Associate(s), Camper(s), Child(ren), Colleague(s), Employee(s), Friend(s), Guest(s), Member(s), Participant(s), Partner(s), Player(s), Spouse(s), Student(s), Teammate(s), Volunteer(s)
254
+ * @type integer $guest_limit Number of guests each registrant can bring, 0 - 100, default = 0
255
+ * @type array $information_sections Determines if the Who (CONTACT), When (TIME), or Where (LOCATION) information is shown on the Event page. Default settings are CONTACT, TIME, and LOCATION ; valid values are
256
+ * CONTACT - displays the event contact information
257
+ * TIME - displays the event date and time
258
+ * LOCATION - displays the event location
259
+ * @type boolean $is_guest_anonymous_enabled Default = false; Set to true to display the guest count field on the registration form; if true, is_guest_name_required must be set to false (default).
260
+ * @type boolean $is_guest_name_required Default = false. Set to display guest name fields on registration form; if true, then is_guest_anonymous_enabled must be set false (default).
261
+ * @type boolean $is_registration_closed_manually Default = false; Manually closes the event registration when set to true, takes precedence over registration_limit_date and registration_limit_count settings
262
+ * @type boolean $is_ticketing_link_displayed Default = false; Set to true provide a link for registrants to retrieve an event ticket after they register.
263
+ * @type string $late_fee_date Date after which late fees apply, in ISO-8601 format
264
+ * @type integer $registration_limit_count Specifies the maximum number of registrants for the event
265
+ * @type string $registration_limit_date Date when event registrations close, in ISO-8601 format
266
+ * }
267
+ */
268
+ public $track_information;
269
+
270
+ /**
271
+ * The event's Twitter hashtag
272
+ * @var string (30)
273
+ */
274
+ public $twitter_hash_tag;
275
+
276
+ /**
277
+ * The event type, valid values are:
278
+ * AUCTION, BIRTHDAY, BUSINESS_FINANCE_SALES
279
+ * CLASSES_WORKSHOPS, COMPETITION_SPORTS
280
+ * CONFERENCES_SEMINARS_FORUM, CONVENTIONS_TRADESHOWS_EXPOS
281
+ * FESTIVALS_FAIRS, FOOD_WINE, FUNDRAISERS_CHARITIES
282
+ * HOLIDAY, INCENTIVE_REWARD_RECOGNITION, MOVIES_FILM
283
+ * MUSIC_CONCERTS, NETWORKING_CLUBS, PERFORMING_ARTS
284
+ * OUTDOORS_RECREATION, RELIGION_SPIRITUALITY
285
+ * SCHOOLS_REUNIONS_ALUMNI, PARTIES_SOCIAL_EVENTS_MIXERS
286
+ * TRAVEL, WEBINAR_TELESEMINAR_TELECLASS
287
+ * WEDDINGS, OTHER
288
+ * @var string
289
+ */
290
+ public $type;
291
+
292
+ /**
293
+ * Date the event was updated in ISO-8601 format
294
+ * @var string
295
+ */
296
+ public $updated_date;
297
+
298
+ /**
299
+ * Factory method to create an Event object from an array
300
+ * @param array $props - associative array of initial properties to set
301
+ * @return EventSpot
302
+ */
303
+ public static function create(array $props)
304
+ {
305
+ $event = new EventSpot();
306
+ $event->id = parent::getValue($props, "id");
307
+ $event->active_date = parent::getValue($props, "active_date");
308
+ if(!empty($props['address'])) {
309
+ $event->address = Address::create( parent::getValue( $props, "address" ) );
310
+ }
311
+ $event->are_registrants_public = parent::getValue($props, "are_registrants_public");
312
+ $event->cancelled_date = parent::getValue($props, "cancelled_date");
313
+ if(!empty( $props['contact'])) {
314
+ $event->contact = Contact::create( parent::getValue( $props, "contact" ) );
315
+ }
316
+ $event->created_date = parent::getValue($props, "created_date");
317
+ $event->currency_type = parent::getValue($props, "currency_type");
318
+ $event->deleted_date = parent::getValue($props, "deleted_date");
319
+ $event->description = parent::getValue($props, "description");
320
+ $event->end_date = parent::getValue($props, "end_date");
321
+ $event->event_detail_url = parent::getValue($props, "event_detail_url");
322
+ $event->google_analytics_key = parent::getValue($props, "google_analytics_key");
323
+ $event->google_merchant_id = parent::getValue($props, "google_merchant_id");
324
+ $event->is_calendar_displayed = parent::getValue($props, "is_calendar_displayed");
325
+ $event->is_checkin_available = parent::getValue($props, "is_checkin_available");
326
+ $event->is_home_page_displayed = parent::getValue($props, "is_home_page_displayed");
327
+ $event->is_listed_in_external_directory = parent::getValue($props, "is_listed_in_external_directory");
328
+ $event->is_map_displayed = parent::getValue($props, "is_map_displayed");
329
+ $event->is_virtual_event = parent::getValue($props, "is_virtual_event");
330
+ $event->location = parent::getValue($props, "location");
331
+ $event->meta_data_tags = parent::getValue($props, "meta_data_tags");
332
+ $event->name = parent::getValue($props, "name");
333
+ if( parent::getValue( $props, "notification_options" ) ) {
334
+ $event->notification_options = NotificationOption::create( parent::getValue( $props, "notification_options" ) );
335
+ }
336
+ $event->online_meeting = parent::getValue($props, "online_meeting");
337
+ $event->payable_to = parent::getValue($props, "payable_to");
338
+ $event->payable_to = parent::getValue($props, "payable_to");
339
+ if( parent::getValue( $props, "payment_address" ) ) {
340
+ $event->payment_address = Address::create( parent::getValue( $props, "payment_address" ) );
341
+ }
342
+ $event->payment_options = parent::getValue($props, "payment_options");
343
+ $event->paypal_account_email = parent::getValue($props, "paypal_account_email");
344
+ $event->registration_url = parent::getValue($props, "registration_url");
345
+ $event->start_date = parent::getValue($props, "start_date");
346
+ $event->status = parent::getValue($props, "status");
347
+ $event->theme_name = parent::getValue($props, "theme_name");
348
+ $event->time_zone_description = parent::getValue($props, "time_zone_description");
349
+ $event->time_zone_id = parent::getValue($props, "time_zone_id");
350
+ $event->title = parent::getValue($props, "title");
351
+ $event->total_registered_count = parent::getValue($props, "total_registered_count");
352
+ if( parent::getValue( $props, "track_information" ) ) {
353
+ $event->track_information = TrackInformation::create( parent::getValue( $props, "track_information" ) );
354
+ }
355
+ $event->twitter_hash_tag = parent::getValue($props, "twitter_hash_tag");
356
+ $event->type = parent::getValue($props, "type");
357
+ $event->updated_date = parent::getValue($props, "updated_date");
358
+
359
+ return $event;
360
+ }
361
+
362
+ public function toJson()
363
+ {
364
+ return json_encode($this);
365
+ }
366
+ }
app/api/Ctct/Components/EventSpot/EventSpotList.php ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Ctct\Components\EventSpot;
3
+
4
+ use Ctct\Components\Component;
5
+
6
+ /**
7
+ * Represents a single Contact List
8
+ *
9
+ * @package Components
10
+ * @subpackage Contacts
11
+ * @author Constant Contact
12
+ */
13
+ class EventSpotList extends Component
14
+ {
15
+ /**
16
+ * Unique identifier of the contact list
17
+ * @var string
18
+ */
19
+ public $id;
20
+
21
+ /**
22
+ * The event title, visible to registrants
23
+ * @var string (100)
24
+ */
25
+ public $title;
26
+
27
+ /**
28
+ * Status of the contact list, must be one of "DRAFT", "ACTIVE", "COMPLETE", "CANCELLED", "DELETED"
29
+ * @var string
30
+ */
31
+ public $status;
32
+
33
+ /**
34
+ * Number of event registrants
35
+ * @var integer
36
+ */
37
+ public $total_registered_count;
38
+
39
+ /**
40
+ * Date event was published or announced, in ISO-8601 format
41
+ * @var string
42
+ */
43
+ public $active_date;
44
+
45
+ /**
46
+ * Date the event was updated in ISO-8601 format
47
+ * @var string
48
+ */
49
+ public $updated_date;
50
+
51
+ /**
52
+ * Factory method to create a EventList object from an array
53
+ * @param array $props - Associative array of initial properties to set
54
+ * @return EventSpotList
55
+ */
56
+ public static function create(array $props)
57
+ {
58
+ $event_list = new EventSpotList();
59
+ $event_list->id = parent::getValue($props, "id");
60
+ $event_list->title = parent::getValue($props, "title");
61
+ $event_list->status = parent::getValue($props, "status");
62
+ $event_list->total_registered_count = parent::getValue($props, "total_registered_count");
63
+ $event_list->created_date = parent::getValue($props, "created_date");
64
+ $event_list->updated_date = parent::getValue($props, "updated_date");
65
+ return $event_list;
66
+ }
67
+
68
+ public function toJson()
69
+ {
70
+ return json_encode($this);
71
+ }
72
+ }
app/api/Ctct/Components/EventSpot/Guest.php ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Ctct\Components\EventSpot;
3
+
4
+ use Ctct\Components\Component;
5
+
6
+ /**
7
+ * Represents a single Contact List
8
+ *
9
+ * @package Components
10
+ * @subpackage EventSpot
11
+ * @author Katz Web Services, Inc.
12
+ */
13
+ class Guest extends Component
14
+ {
15
+ /**
16
+ * Unique identifier of the contact list
17
+ * @var string
18
+ */
19
+ public $guest_id;
20
+
21
+ /**
22
+ * The event title, visible to registrants
23
+ * @var string (100)
24
+ */
25
+ public $guest_section;
26
+
27
+ /**
28
+ * Factory method to create a EventList object from an array
29
+ * @param array $props - Associative array of initial properties to set
30
+ * @return Guest
31
+ */
32
+ public static function create(array $props)
33
+ {
34
+ $guest = new Guest();
35
+ $guest->guest_id = parent::getValue($props, "guest_id");
36
+ $guest->guest_section = GuestSection::create(parent::getValue($props, "guest_section"));
37
+ return $guest;
38
+ }
39
+ }
app/api/Ctct/Components/EventSpot/GuestSection.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Ctct\Components\EventSpot;
3
+
4
+ use Ctct\Components\Component;
5
+
6
+ /**
7
+ * Represents a single Contact List
8
+ *
9
+ * @package Components
10
+ * @subpackage Contacts
11
+ * @author Constant Contact
12
+ */
13
+ class GuestSection extends Component
14
+ {
15
+ /**
16
+ * The section label
17
+ * @var string
18
+ */
19
+ public $label;
20
+
21
+ /**
22
+ * An array of the fields displayed on the event registration page, and the values the registrant entered.
23
+ * @var GuestSectionField[]
24
+ */
25
+ public $fields = array();
26
+
27
+ /**
28
+ * Factory method to create a EventList object from an array
29
+ * @param array $props - Associative array of initial properties to set
30
+ * @return GuestSection
31
+ */
32
+ public static function create(array $props)
33
+ {
34
+ $guest_section = new GuestSection();
35
+
36
+ $guest_section->label = parent::getValue($props, "label");
37
+
38
+ if (isset($props['fields'])) {
39
+ foreach ($props['fields'] as $field) {
40
+ $guest_section->fields[] = GuestSectionField::create($field);
41
+ }
42
+ }
43
+ return $guest_section;
44
+ }
45
+ }
app/api/Ctct/Components/EventSpot/GuestSectionField.php ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Ctct\Components\EventSpot;
3
+
4
+ use Ctct\Components\Component;
5
+
6
+ /**
7
+ * Represents a single Contact List
8
+ *
9
+ * @package Components
10
+ * @subpackage EventSpot
11
+ * @author Katz Web Services, Inc.
12
+ */
13
+ class GuestSectionField extends Component
14
+ {
15
+ /**
16
+ * Type of field - Either single_value or multiple_values
17
+ * @var string
18
+ */
19
+ public $type;
20
+
21
+ /**
22
+ * Field label displayed on the event registration page, typical values are NAME_FIRST, NAME_LAST, EMAIL_ADDRESS
23
+ * @var string
24
+ */
25
+ public $label;
26
+
27
+ /**
28
+ * Name of the field
29
+ * @var string
30
+ */
31
+ public $name;
32
+
33
+ /**
34
+ * Value entered by registrant, used if field_typetype = single_value
35
+ * @var string
36
+ */
37
+ public $value;
38
+
39
+ /**
40
+ * An array of values entered by registrant, used if field_type = multiple_values
41
+ * @var array
42
+ */
43
+ public $values;
44
+
45
+ /**
46
+ * Factory method to create a EventList object from an array
47
+ * @param array $props - Associative array of initial properties to set
48
+ * @return GuestSectionField
49
+ */
50
+ public static function create(array $props)
51
+ {
52
+ $guest_section_field = new GuestSectionField();
53
+
54
+ $guest_section_field->type = parent::getValue($props, "type");
55
+ $guest_section_field->name = parent::getValue($props, "name");
56
+ $guest_section_field->label = parent::getValue($props, "label");
57
+ $guest_section_field->value = parent::getValue($props, "value");
58
+ $guest_section_field->values = parent::getValue($props, "values");
59
+
60
+ return $guest_section_field;
61
+ }
62
+ }
app/api/Ctct/Components/EventSpot/NotificationOption.php ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Ctct\Components\EventSpot;
3
+
4
+ use Ctct\Components\Component;
5
+
6
+ /**
7
+ * Represents a method of notifications for an Event
8
+ *
9
+ * @package Components
10
+ * @subpackage EventSpot
11
+ * @author Katz Web Services, Inc.
12
+ */
13
+ class NotificationOption extends Component
14
+ {
15
+ /**
16
+ * Set to true to send event notifications to the contact email_address, false for no notifications; default = false
17
+ * @var boolean
18
+ */
19
+ public $is_opted_in;
20
+
21
+ /**
22
+ * Specifies the type of notifications sent to the contact email_address, valid values: SO_REGISTRATION_NOTIFICATION - send notice for each registration (Default)
23
+ * @var string
24
+ */
25
+ public $notification_type;
26
+
27
+ /**
28
+ * Factory method to create a NotificationOption object from an array
29
+ * @param array $props - Associative array of initial properties to set
30
+ * @return NotificationOption
31
+ */
32
+ public static function create(array $props)
33
+ {
34
+ $notification_option = new NotificationOption();
35
+ $notification_option->is_opted_in = parent::getValue($props, "guest_id");
36
+ $notification_option->notification_type = parent::getValue($props, "notification_type");
37
+ return $notification_option;
38
+ }
39
+ }
app/api/Ctct/Components/EventSpot/OnlineMeeting.php ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Ctct\Components\EventSpot;
3
+
4
+ use Ctct\Components\Component;
5
+
6
+ /**
7
+ * Represents details for an online meeting Event
8
+ *
9
+ * @package Components
10
+ * @subpackage EventSpot
11
+ * @author Katz Web Services, Inc.
12
+ */
13
+ class OnlineMeeting extends Component
14
+ {
15
+ /**
16
+ * Online meeting instructions, such as dial in number, password, etc
17
+ * @var string (2500)
18
+ */
19
+ public $instructions;
20
+
21
+ /**
22
+ * Meeting ID, if any, for the meeting
23
+ * @var string (50)
24
+ */
25
+ public $provider_meeting_id;
26
+
27
+ /**
28
+ * Specify the online meeting provider, such as WebEx
29
+ * @var string (20)
30
+ */
31
+ public $provider_type;
32
+
33
+ /**
34
+ * URL for online meeting. REQUIRED if Event `is_virtual_event` is set to true.
35
+ * @var string (250)
36
+ */
37
+ public $url;
38
+
39
+ /**
40
+ * Factory method to create a OnlineMeeting object from an array
41
+ * @param array $props - Associative array of initial properties to set
42
+ * @return OnlineMeeting
43
+ */
44
+ public static function create(array $props)
45
+ {
46
+ $online_meeting = new OnlineMeeting();
47
+ $online_meeting->is_opted_in = parent::getValue($props, "guest_id");
48
+ $online_meeting->notification_type = parent::getValue($props, "notification_type");
49
+ return $online_meeting;
50
+ }
51
+ }
app/api/Ctct/Components/EventSpot/PaymentSummary.php ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Ctct\Components\EventSpot;
3
+
4
+ use Ctct\Components\Component;
5
+ use Ctct\Components\EventSpot\Registrant\RegistrantOrder;
6
+ use Ctct\Components\EventSpot\Registrant\RegistrantPromoCode;
7
+
8
+ /**
9
+ * Represents a single Contact List
10
+ *
11
+ * @package Components
12
+ * @subpackage Contacts
13
+ * @author Constant Contact
14
+ */
15
+ class PaymentSummary extends Component
16
+ {
17
+ /**
18
+ * Displays the payment_status and payment_type
19
+ * payment_status - Registrant's payment status:
20
+ * PENDING - default for cash (at door) or check payments
21
+ * NA - default free event status
22
+ * INCOMPLETE - default PayPal status
23
+ * FAILED - PayPal payment failed
24
+ * REFUNDED - Fee refunded to registrant (for PayPal only)
25
+ * PAID
26
+ * @var string
27
+ */
28
+ public $payment_status;
29
+
30
+ /**
31
+ * Payment type registrant used - CHECK, DOOR, ONLINE_CREDIT_CARD_PROCESSOR, PAYPAL, GOOGLE_CHECKOUT
32
+ * @var string (100)
33
+ */
34
+ public $payment_type;
35
+
36
+ /**
37
+ * Array of properties showing the registrant's total order.
38
+ * @var RegistrantOrder
39
+ */
40
+ public $order;
41
+
42
+ /**
43
+ * @var RegistrantPromoCode
44
+ */
45
+ public $promo_code;
46
+
47
+ /**
48
+ * Factory method to create a EventList object from an array
49
+ * @param array $props - Associative array of initial properties to set
50
+ * @return PaymentSummary
51
+ */
52
+ public static function create(array $props)
53
+ {
54
+ $payment_summary = new PaymentSummary();
55
+ $payment_summary->payment_status = parent::getValue($props, "payment_status");
56
+ $payment_summary->payment_type = parent::getValue($props, "payment_type");
57
+
58
+ if( isset($props["order"])) {
59
+ $payment_summary->order = RegistrantOrder::create( parent::getValue( $props, "order" ) );
60
+ }
61
+
62
+ if (!empty($props['promo_code'])) {
63
+ $payment_summary->promo_code = RegistrantPromoCode::create($props['promo_code']);
64
+ }
65
+
66
+ return $payment_summary;
67
+ }
68
+
69
+ public function toJson()
70
+ {
71
+ return json_encode($this);
72
+ }
73
+ }
app/api/Ctct/Components/EventSpot/Promocode.php ADDED
@@ -0,0 +1,127 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Ctct\Components\EventSpot\Registrant;
3
+
4
+ use Ctct\Components\Component;
5
+
6
+ /**
7
+ * Represents a single Promo Code
8
+ *
9
+ * @package Components
10
+ * @subpackage EventSpot\Registrant
11
+ * @author Katz Web Services, Inc.
12
+ */
13
+ class Promocode extends Component
14
+ {
15
+ /**
16
+ * Name of the promotional code visible to registrants, between 4 - 12 characters, cannot contain spaces or special character (_ is OK); each code_name must be unique
17
+ * @var string
18
+ */
19
+ public $code_name;
20
+
21
+ /**
22
+ * Type of promocode redeemed, ACCESS or DISCOUNT
23
+ * ACCESS - applies to a specific fee with has_restricted_access` = true, `fee_list` must include only a single `fee_id`.
24
+ * DISCOUNT - when set to DISCOUNT, you must specify either a `discount_percent` or a `discount_amount`
25
+ * @var string
26
+ */
27
+ public $code_type;
28
+
29
+ /**
30
+ * Specifies a fixed discount amount, minimum of 0.01, is required when `code_type` = DISCOUNT, but not using `discount_percent`
31
+ * @var float
32
+ */
33
+ public $discount_amount;
34
+
35
+ /**
36
+ * Specifies a discount percentage, from 1% - 100%, is required when `code_type` = DISCOUNT, but not using `discount_amount`
37
+ * @var float|int
38
+ */
39
+ public $discount_percent;
40
+
41
+ /**
42
+ * Discount scope - FEE_LIST or ORDER_TOTAL
43
+ * @var string
44
+ */
45
+ public $discount_scope;
46
+
47
+ /**
48
+ * Discount types:
49
+ * PERCENT - discount is a percentage specified by `discount_percent`
50
+ * AMOUNT - discount is a fixed amount, specified by `discount_amount`
51
+ * @var string
52
+ */
53
+ public $discount_type;
54
+
55
+ /**
56
+ * Identifies the fees to which the promocode applies;
57
+ * If `code_type` = ACCESS promocode applies to a single fee with `has_restricted_access` = true, include only 1 fee id
58
+ * If `code_type` = DISCOUNT and `discount_scope` = ORDER_TOTAL, do not include any `fee_ids`
59
+ * If `code_type` = DISCOUNT and `discount_scope` = FEE_LIST, then include all `fee_ids` to which the discount applies
60
+ * @var array
61
+ */
62
+ public $fee_ids;
63
+
64
+ /**
65
+ * Unique ID for the event promotional code
66
+ * @var string (50)
67
+ */
68
+ public $id;
69
+
70
+ /**
71
+ * When set to true, promocode cannot be redeemed; when false, promocode can be redeemed; default = false.
72
+ * @var boolean
73
+ */
74
+ public $is_paused;
75
+
76
+ /**
77
+ * Number of promocodes available for redemption; -1 = unlimited.
78
+ * @var integer
79
+ */
80
+ public $quantity_available;
81
+
82
+ /**
83
+ * Total number of promocodes available for redemption; -1 = unlimited.
84
+ * @var integer
85
+ */
86
+ public $quantity_total;
87
+
88
+ /**
89
+ * Number of promocodes that have been redeemed; starts at 0.
90
+ * @var integer
91
+ */
92
+ public $quantity_used;
93
+
94
+ /**
95
+ * Status of the promocode:
96
+ * LIVE - promocode is available to be redeemed
97
+ * PAUSED - promocode is not available for redemption
98
+ * DEPLETED - no more promocodes remain, quantity_available = 0
99
+ * @var string
100
+ */
101
+ public $status;
102
+
103
+ /**
104
+ * Factory method to create a EventList object from an array
105
+ * @param array $props - Associative array of initial properties to set
106
+ * @return RegistrantPromoCodeInfo
107
+ */
108
+ public static function create(array $props)
109
+ {
110
+ $promocode = new RegistrantPromoCodeInfo();
111
+ $promocode->code_name = parent::getValue($props, "code_name");
112
+ $promocode->code_type = parent::getValue($props, "code_type");
113
+ $promocode->discount_amount = parent::getValue($props, "discount_amount");
114
+ $promocode->discount_percent = parent::getValue($props, "discount_percent");
115
+ $promocode->discount_scope = parent::getValue($props, "discount_scope");
116
+ $promocode->discount_type = parent::getValue($props, "discount_type");
117
+ $promocode->id = parent::getValue($props, "id");
118
+ $promocode->fee_ids = parent::getValue($props, "fee_ids");
119
+ $promocode->is_paused = parent::getValue($props, "is_paused");
120
+ $promocode->quantity_available = parent::getValue($props, "quantity_available");
121
+ $promocode->quantity_total = parent::getValue($props, "quantity_total");
122
+ $promocode->quantity_used = parent::getValue($props, "quantity_used");
123
+ $promocode->status = parent::getValue($props, "status");
124
+
125
+ return $promocode;
126
+ }
127
+ }
app/api/Ctct/Components/EventSpot/Registrant/Registrant.php ADDED
@@ -0,0 +1,188 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Ctct\Components\EventSpot\Registrant;
3
+
4
+ use Ctct\Components\Component;
5
+ use Ctct\Components\EventSpot\Promocode;
6
+ use Ctct\Components\EventSpot\Guest;
7
+ use Ctct\Components\EventSpot\PaymentSummary;
8
+
9
+
10
+ /**
11
+ * Represents a single Contact List
12
+ *
13
+ * @package Components
14
+ * @subpackage Contacts
15
+ * @author Katz Web Services, Inc.
16
+ */
17
+ class Registrant extends Component
18
+ {
19
+ /**
20
+ * Unique identifier of the contact list
21
+ * @var string
22
+ */
23
+ public $id;
24
+
25
+ /**
26
+ * The Registrant's attendance status, ATTENDED or NOT_ATTENDED
27
+ * @var string
28
+ */
29
+ public $attendance_status;
30
+
31
+ /**
32
+ * The Registrant's email address
33
+ * @var string
34
+ */
35
+ public $email;
36
+
37
+ /**
38
+ * The Registrant's first (given) name
39
+ * @var string
40
+ */
41
+ public $first_name;
42
+
43
+ /**
44
+ * The Registrant's last (family) name
45
+ * @var string
46
+ */
47
+ public $last_name;
48
+
49
+ /**
50
+ * Number of guests the registrant is bringing to the event
51
+ * @var integer
52
+ */
53
+ public $guest_count;
54
+
55
+ /**
56
+ * The Registrant's payment status
57
+ * @var string
58
+ */
59
+ public $payment_status;
60
+
61
+ /**
62
+ * Date the event was updated in ISO-8601 format
63
+ * @var string
64
+ */
65
+ public $registration_date;
66
+
67
+ /**
68
+ * Registrant's registration status, valid values are:
69
+ * REGISTERED
70
+ * CANCELLED - Registration was cancelled
71
+ * ABANDONED - The registrant completed the registration form but did not complete the online payment process
72
+ * through PayPal, ProPay or Authorize.net; abandoned registrants are not included in registration reports.
73
+ * @var string
74
+ */
75
+ public $registration_status;
76
+
77
+ /**
78
+ * Unique ID of the registrant's event ticket
79
+ * @var string
80
+ */
81
+ public $ticket_id;
82
+
83
+ /**
84
+ * Date the event was updated in ISO-8601 format
85
+ * @var string
86
+ */
87
+ public $updated_date;
88
+
89
+ /**
90
+ * Displays the payment_status and payment_type
91
+ * payment_status - Registrant's payment status:
92
+ * PENDING - default for cash (at door) or check payments
93
+ * NA - default free event status
94
+ * INCOMPLETE - default PayPal status
95
+ * FAILED - PayPal payment failed
96
+ * REFUNDED - Fee refunded to registrant (for PayPal only)
97
+ * PAID
98
+ * @var array
99
+ */
100
+ public $payment_summary;
101
+
102
+ /**
103
+ * Displays registrant's personal information, grouped by the fields displayed on the event registration page
104
+ * @var RegistrantSection[]
105
+ */
106
+ public $sections = array();
107
+
108
+ /**
109
+ * Contains all the guest information fields and values, entered by the registrant on the event registration page.
110
+ * @var Guest[]
111
+ */
112
+ public $guests = array();
113
+
114
+ /**
115
+ * Factory method to create a EventList object from an array
116
+ * @param array $props - Associative array of initial properties to set
117
+ * @return Registrant
118
+ */
119
+ public static function create(array $props)
120
+ {
121
+ $event_registrant = new Registrant();
122
+ $event_registrant->attendance_status = parent::getValue($props, "attendance_status");
123
+ $event_registrant->id = parent::getValue($props, "id");
124
+ $event_registrant->registration_date = parent::getValue($props, "registration_date");
125
+ $event_registrant->registration_status = parent::getValue($props, "registration_status");
126
+ $event_registrant->ticket_id = parent::getValue($props, "ticket_id");
127
+ $event_registrant->updated_date = parent::getValue($props, "updated_date");
128
+
129
+ if ( isset( $props['payment_summary'] ) ) {
130
+ $event_registrant->payment_summary = PaymentSummary::create( $props['payment_summary'] );
131
+ $event_registrant->payment_status = $event_registrant->payment_summary->payment_status;
132
+ } else {
133
+ $event_registrant->payment_status = parent::getValue($props, "payment_status");
134
+ }
135
+
136
+
137
+ if ( !empty( $props['sections'] ) ) {
138
+ foreach ($props['sections'] as $section) {
139
+ $event_registrant->sections[] = RegistrantSection::create($section);
140
+ }
141
+ }
142
+
143
+ $event_registrant->email = isset( $props['email'] ) ? parent::getValue($props, "email") : $event_registrant->getFieldValue('EMAIL_ADDRESS');
144
+ $event_registrant->first_name = isset( $props['first_name'] ) ? parent::getValue($props, "first_name") : $event_registrant->getFieldValue('NAME_FIRST');
145
+ $event_registrant->last_name = isset( $props['last_name'] ) ? parent::getValue($props, "last_name") : $event_registrant->getFieldValue('NAME_LAST');
146
+
147
+ if (!empty($props['guests']) && isset( $props['guests']['guest_info'] ) ) {
148
+
149
+ $event_registrant->guest_count = $props['guests']['guest_count'];
150
+
151
+ foreach ($props['guests']['guest_info'] as $guest) {
152
+ $event_registrant->guests[] = Guest::create($guest);
153
+ }
154
+ } else {
155
+ $event_registrant->guest_count = parent::getValue($props, "guest_count");
156
+ }
157
+
158
+ return $event_registrant;
159
+ }
160
+
161
+ /**
162
+ * Get a field value from the RegistrantSection storage by field name
163
+ *
164
+ * @param string $fieldName Name of the field to get for the Registrant, like "NAME_LAST" or "CUSTOM1"
165
+ *
166
+ * @return string|array|null For single_value field types, returns string. For multiple_value field types, returns array. If not found, returns null
167
+ */
168
+ public function getFieldValue( $fieldName ) {
169
+
170
+ /** @var RegistrantSection $section */
171
+ foreach ( $this->sections as $section ) {
172
+
173
+ /** @var RegistrantSectionField $field */
174
+ foreach ( $section->fields as $field ) {
175
+ if( $fieldName === $field->name ) {
176
+ return is_null( $field->values ) ? $field->value : $field->values;
177
+ }
178
+ }
179
+ }
180
+
181
+ return null;
182
+ }
183
+
184
+ public function toJson()
185
+ {
186
+ return json_encode($this);
187
+ }
188
+ }
app/api/Ctct/Components/EventSpot/Registrant/RegistrantFee.php ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Ctct\Components\EventSpot\Registrant;
3
+
4
+ use Ctct\Components\Component;
5
+
6
+ /**
7
+ * Represents a single Promo Code
8
+ *
9
+ * @package Components
10
+ * @subpackage EventSpot\Registrant
11
+ * @author Katz Web Services, Inc.
12
+ */
13
+ class RegistrantFee extends Component
14
+ {
15
+ /**
16
+ * Unique ID of the fee that the registrant paid
17
+ * @var string
18
+ */
19
+ public $id;
20
+
21
+ /**
22
+ * Full name of the registrant or guest
23
+ * @var string
24
+ */
25
+ public $name;
26
+
27
+ /**
28
+ * The name of the fee that the registrant paid
29
+ * @var string
30
+ */
31
+ public $type;
32
+
33
+ /**
34
+ * Percentage of discount, if discount_type = PERCENTAGE
35
+ * @var int
36
+ */
37
+ public $quantity;
38
+
39
+ /**
40
+ * The fee amount
41
+ * @var float
42
+ */
43
+ public $amount;
44
+
45
+ /**
46
+ * Identifies if the fee paid was an early, late, or regular fee
47
+ * @var string
48
+ */
49
+ public $fee_period_type;
50
+
51
+ /**
52
+ * The type of promotional code redeemed, ACCESS or DISCOUNT
53
+ * @internal May be deprecated.
54
+ * @var string
55
+ */
56
+ public $promo_type;
57
+
58
+ /**
59
+ * Factory method to create a EventList object from an array
60
+ * @param array $props - Associative array of initial properties to set
61
+ * @return RegistrantPromoCodeInfo
62
+ */
63
+ public static function create(array $props)
64
+ {
65
+ $registrant_fee = new RegistrantFee();
66
+ $registrant_fee->id = parent::getValue($props, "id");
67
+ $registrant_fee->name = parent::getValue($props, "name");
68
+ $registrant_fee->type = parent::getValue($props, "type");
69
+ $registrant_fee->quantity = parent::getValue($props, "quantity");
70
+ $registrant_fee->amount = parent::getValue($props, "amount");
71
+ $registrant_fee->fee_period_type = parent::getValue($props, "fee_period_type");
72
+ $registrant_fee->promo_type = parent::getValue($props, "promo_type");
73
+
74
+ return $registrant_fee;
75
+ }
76
+ }
app/api/Ctct/Components/EventSpot/Registrant/RegistrantOrder.php ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Ctct\Components\EventSpot\Registrant;
3
+
4
+ use Ctct\Components\Component;
5
+ use Ctct\Components\EventSpot\Registrant\RegistrantFee;
6
+
7
+ /**
8
+ * Represents an order placed by an event Registrant
9
+ *
10
+ * @package Components
11
+ * @subpackage EventSpot\Registrant
12
+ * @author Katz Web Services, Inc.
13
+ */
14
+ class RegistrantOrder extends Component
15
+ {
16
+ /**
17
+ * Order ID
18
+ * @var string
19
+ */
20
+ public $order_id;
21
+
22
+ /**
23
+ * Date and time the order was placed, in ISO-8601 format.
24
+ * @var string
25
+ */
26
+ public $order_date;
27
+
28
+ /**
29
+ * Currency type used
30
+ * @var string
31
+ */
32
+ public $currency_type;
33
+
34
+ /**
35
+ * Identifies if the fee paid was an early, late, or regular fee
36
+ * @var float
37
+ */
38
+ public $total;
39
+
40
+ /**
41
+ * An array of fee properties.
42
+ * @var RegistrantFee[]
43
+ */
44
+ public $fees = array();
45
+
46
+ /**
47
+ * Factory method to create a EventList object from an array
48
+ * @param array $props - Associative array of initial properties to set
49
+ * @return RegistrantPromoCodeInfo
50
+ */
51
+ public static function create(array $props)
52
+ {
53
+ $registrant_order = new RegistrantOrder();
54
+ $registrant_order->order_id = parent::getValue($props, "order_id");
55
+ $registrant_order->order_date = parent::getValue($props, "order_date");
56
+ $registrant_order->currency_type = parent::getValue($props, "currency_type");
57
+ $registrant_order->total = parent::getValue($props, "total");
58
+
59
+ if( isset($props['fees']) ) {
60
+ foreach ( $props['fees'] as $fee ) {
61
+ $registrant_order->fees[] = RegistrantFee::create($fee);
62
+ }
63
+ }
64
+
65
+ return $registrant_order;
66
+ }
67
+ }
app/api/Ctct/Components/EventSpot/Registrant/RegistrantPromocode.php ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Ctct\Components\EventSpot\Registrant;
3
+
4
+ use Ctct\Components\Component;
5
+
6
+ /**
7
+ * Represents a single Promo Code
8
+ *
9
+ * @package Components
10
+ * @subpackage EventSpot\Registrant
11
+ * @author Katz Web Services, Inc.
12
+ */
13
+ class RegistrantPromoCode extends Component
14
+ {
15
+ /**
16
+ * Unique identifier of the contact list
17
+ * @var float|int
18
+ */
19
+ public $total_discount;
20
+
21
+ /**
22
+ * Displays information for any promocodes redeemed with this order.
23
+ * @var RegistrantPromoCodeInfo
24
+ */
25
+ public $promo_code_info;
26
+
27
+ /**
28
+ * Factory method to create a EventList object from an array
29
+ * @param array $props - Associative array of initial properties to set
30
+ * @return RegistrantPromoCode
31
+ */
32
+ public static function create(array $props)
33
+ {
34
+ $registrant_promo_code = new RegistrantPromoCode();
35
+ $registrant_promo_code->total_discount = parent::getValue($props, "total_discount");
36
+ $registrant_promo_code->promo_code_info = RegistrantPromoCodeInfo::create(parent::getValue($props, "promo_code_info"));
37
+ return $registrant_promo_code;
38
+ }
39
+ }
app/api/Ctct/Components/EventSpot/Registrant/RegistrantPromocodeInfo.php ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Ctct\Components\EventSpot\Registrant;
3
+
4
+ use Ctct\Components\Component;
5
+
6
+ /**
7
+ * Represents a single Promo Code
8
+ *
9
+ * @package Components
10
+ * @subpackage EventSpot\Registrant
11
+ * @author Katz Web Services, Inc.
12
+ */
13
+ class RegistrantPromoCodeInfo extends Component
14
+ {
15
+ /**
16
+ * The promocode name
17
+ * @var string
18
+ */
19
+ public $code_name;
20
+
21
+ /**
22
+ * Type of promocode redeemed, ACCESS or DISCOUNT
23
+ * @var string
24
+ */
25
+ public $code_type;
26
+
27
+ /**
28
+ * Amount of each discount, if discount_type = AMOUNT
29
+ * @var float
30
+ */
31
+ public $discount_amount;
32
+
33
+ /**
34
+ * Percentage of discount, if discount_type = PERCENTAGE
35
+ * @var float|int
36
+ */
37
+ public $discount_percent;
38
+
39
+ /**
40
+ * Discount scope - FEE_LIST or ORDER_TOTAL
41
+ * @var string
42
+ */
43
+ public $discount_scope;
44
+
45
+ /**
46
+ * Discount type - either PERCENTAGE or AMOUNT
47
+ * @var string
48
+ */
49
+ public $discount_type;
50
+
51
+ /**
52
+ * Number of promocodes redeemed in this order
53
+ * @var int
54
+ */
55
+ public $redemption_count;
56
+
57
+ /**
58
+ * Factory method to create a EventList object from an array
59
+ * @param array $props - Associative array of initial properties to set
60
+ * @return RegistrantPromoCodeInfo
61
+ */
62
+ public static function create(array $props)
63
+ {
64
+ $registrant_promo_code_info = new RegistrantPromoCodeInfo();
65
+ $registrant_promo_code_info->code_name = parent::getValue($props, "code_name");
66
+ $registrant_promo_code_info->code_type = parent::getValue($props, "code_type");
67
+ $registrant_promo_code_info->discount_amount = parent::getValue($props, "discount_amount");
68
+ $registrant_promo_code_info->discount_percent = parent::getValue($props, "discount_percent");
69
+ $registrant_promo_code_info->discount_scope = parent::getValue($props, "discount_scope");
70
+ $registrant_promo_code_info->discount_type = parent::getValue($props, "discount_type");
71
+ $registrant_promo_code_info->redemption_count = parent::getValue($props, "redemption_count");
72
+
73
+ return $registrant_promo_code_info;
74
+ }
75
+ }
app/api/Ctct/Components/EventSpot/Registrant/RegistrantSection.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Ctct\Components\EventSpot\Registrant;
3
+
4
+ use Ctct\Components\Component;
5
+
6
+ /**
7
+ * Represents a single Contact List
8
+ *
9
+ * @package Components
10
+ * @subpackage Contacts
11
+ * @author Constant Contact
12
+ */
13
+ class RegistrantSection extends Component
14
+ {
15
+ /**
16
+ * The section label
17
+ * @var string
18
+ */
19
+ public $label;
20
+
21
+ /**
22
+ * An array of the fields displayed on the event registration page, and the values the registrant entered.
23
+ * @var RegistrantSectionField[]
24
+ */
25
+ public $fields;
26
+
27
+ /**
28
+ * Factory method to create a EventList object from an array
29
+ * @param array $props - Associative array of initial properties to set
30
+ * @return RegistrantSection
31
+ */
32
+ public static function create(array $props)
33
+ {
34
+ $registrant_section = new RegistrantSection();
35
+ $registrant_section->label = parent::getValue($props, "label");
36
+
37
+ if (isset($props['fields'])) {
38
+ foreach ($props['fields'] as $field) {
39
+ $registrant_section->fields[] = RegistrantSectionField::create($field);
40
+ }
41
+ }
42
+
43
+ return $registrant_section;
44
+ }
45
+ }
app/api/Ctct/Components/EventSpot/Registrant/RegistrantSectionField.php ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Ctct\Components\EventSpot\Registrant;
3
+
4
+ use Ctct\Components\Component;
5
+
6
+ /**
7
+ * Represents a single Contact List
8
+ *
9
+ * @package Components
10
+ * @subpackage Contacts
11
+ * @author Constant Contact
12
+ */
13
+ class RegistrantSectionField extends Component
14
+ {
15
+ /**
16
+ * Type of field - Either single_value or multiple_values
17
+ * @var string
18
+ */
19
+ public $type;
20
+
21
+ /**
22
+ * Name of the field
23
+ * @var string
24
+ */
25
+ public $name;
26
+
27
+ /**
28
+ * Field label displayed on the event registration page, typical values are NAME_FIRST, NAME_LAST, EMAIL_ADDRESS
29
+ * @var string
30
+ */
31
+ public $label;
32
+
33
+ /**
34
+ * Value entered by registrant, used if field_typetype = single_value
35
+ * @var string
36
+ */
37
+ public $value;
38
+
39
+ /**
40
+ * An array of values entered by registrant, used if field_type = multiple_values
41
+ * @var array
42
+ */
43
+ public $values;
44
+
45
+ /**
46
+ * Factory method to create a EventList object from an array
47
+ * @param array $props - Associative array of initial properties to set
48
+ * @return RegistrantSectionField
49
+ */
50
+ public static function create(array $props)
51
+ {
52
+ $field = new RegistrantSectionField();
53
+ $field->type = parent::getValue($props, "type");
54
+ $field->name = parent::getValue($props, "name");
55
+ $field->label = parent::getValue($props, "label");
56
+ $field->value = parent::getValue($props, "value");
57
+ $field->values = parent::getValue($props, "values");
58
+ return $field;
59
+ }
60
+
61
+ public function toJson()
62
+ {
63
+ return json_encode($this);
64
+ }
65
+ }
app/api/Ctct/Components/EventSpot/TrackInformation.php ADDED
@@ -0,0 +1,103 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Ctct\Components\EventSpot;
3
+
4
+ use Ctct\Components\Component;
5
+
6
+ /**
7
+ * Defines the information displayed on the Event registration page
8
+ *
9
+ * @package Components
10
+ * @subpackage EventSpot
11
+ * @author Katz Web Services, Inc.
12
+ */
13
+ class TrackInformation extends Component
14
+ {
15
+
16
+ /**
17
+ * Date on which early fees end, in ISO-8601 format
18
+ * @var string
19
+ */
20
+ public $early_fee_date;
21
+
22
+ /**
23
+ * Default = Guest(s); How guests are referred to on the registration form; use your own, or one of the following suggestions are Associate(s), Camper(s), Child(ren), Colleague(s), Employee(s), Friend(s), Guest(s), Member(s), Participant(s), Partner(s), Player(s), Spouse(s), Student(s), Teammate(s), Volunteer(s)
24
+ * @var string (50)
25
+ */
26
+ public $guest_display_label;
27
+
28
+ /**
29
+ * Number of guests each registrant can bring, 0 - 100, default = 0
30
+ * @var int
31
+ */
32
+ public $guest_limit;
33
+
34
+ /**
35
+ * Determines if the Who (CONTACT), When (TIME), or Where (LOCATION) information is shown on the Event page. Default settings are `CONTACT`, `TIME`, and `LOCATION` ; valid values are: `CONTACT` - displays the event contact information, `TIME` - displays the event date and time, `LOCATION` - displays the event location
36
+ * @var array
37
+ */
38
+ public $information_sections;
39
+
40
+ /**
41
+ * Default = false; Set to true to display the guest count field on the registration form; if true, `is_guest_name_required` must be set to false (default).
42
+ * @var boolean
43
+ */
44
+ public $is_guest_anonymous_enabled;
45
+
46
+ /**
47
+ * Default = false. Set to display guest name fields on registration form; if true, then `is_guest_anonymous_enabled` must be set false (default).
48
+ * @var boolean
49
+ */
50
+ public $is_guest_name_required;
51
+
52
+ /**
53
+ * Default = false; Manually closes the event registration when set to true, takes precedence over `registration_limit_date` and `registration_limit_count` settings
54
+ * @var boolean
55
+ */
56
+ public $is_registration_closed_manually;
57
+
58
+ /**
59
+ * Default = false; Set to true provide a link for registrants to retrieve an event ticket after they register.
60
+ * @var boolean
61
+ */
62
+ public $is_ticketing_link_displayed;
63
+
64
+ /**
65
+ * Date after which late fees apply, in ISO-8601 format
66
+ * @var string
67
+ */
68
+ public $late_fee_date;
69
+
70
+ /**
71
+ * Specifies the maximum number of registrants for the event
72
+ * @var integer
73
+ */
74
+ public $registration_limit_count;
75
+
76
+ /**
77
+ * Date when event registrations close, in ISO-8601 format
78
+ * @var string
79
+ */
80
+ public $registration_limit_date;
81
+
82
+ /**
83
+ * Factory method to create a NotificationOption object from an array
84
+ * @param array $props - Associative array of initial properties to set
85
+ * @return TrackInformation
86
+ */
87
+ public static function create(array $props)
88
+ {
89
+ $track_information = new TrackInformation();
90
+ $track_information->early_fee_date = parent::getValue($props, "early_fee_date");
91
+ $track_information->guest_display_label = parent::getValue($props, "guest_display_label");
92
+ $track_information->guest_limit = parent::getValue($props, "guest_limit");
93
+ $track_information->information_sections = parent::getValue($props, "information_sections");
94
+ $track_information->is_guest_anonymous_enabled = parent::getValue($props, "is_guest_anonymous_enabled");
95
+ $track_information->is_guest_name_required = parent::getValue($props, "is_guest_name_required");
96
+ $track_information->is_registration_closed_manually = parent::getValue($props, "is_registration_closed_manually");
97
+ $track_information->is_ticketing_link_displayed = parent::getValue($props, "is_ticketing_link_displayed");
98
+ $track_information->late_fee_date = parent::getValue($props, "late_fee_date");
99
+ $track_information->registration_limit_count = parent::getValue($props, "registration_limit_count");
100
+ $track_information->registration_limit_date = parent::getValue($props, "registration_limit_date");
101
+ return $track_information;
102
+ }
103
+ }
app/api/Ctct/Components/Library/File.php ADDED
@@ -0,0 +1,152 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Ctct\Components\Library;
3
+
4
+ use Ctct\Components\Component;
5
+
6
+ /**
7
+ * Represents a single File in a Constant Contact Library
8
+ *
9
+ * @package Components
10
+ * @subpackage Library
11
+ * @author Constant Contact
12
+ */
13
+ class File extends Component {
14
+ /**
15
+ * The ID of the file
16
+ * @var String
17
+ */
18
+ public $id;
19
+
20
+ /**
21
+ * The name of the file
22
+ * @var String
23
+ */
24
+ public $name;
25
+
26
+ /**
27
+ * The file's description
28
+ * @var String
29
+ */
30
+ public $description;
31
+
32
+ /**
33
+ * The name of the folder that the file is in
34
+ * @var String
35
+ */
36
+ public $folder;
37
+
38
+ /**
39
+ * The ID of the folder that the file is in
40
+ * @var String
41
+ */
42
+ public $folder_id;
43
+
44
+ /**
45
+ * Is this file an image?
46
+ * @var Boolean
47
+ */
48
+ public $is_image;
49
+
50
+ /**
51
+ * Type of the file, must be one of "JPG", "GIF", "PDF", "PNG", "DOC", "XLS", "PPT", "DOCX", "XLSX", "PPTX"
52
+ * @var String
53
+ */
54
+ public $type;
55
+
56
+ /**
57
+ * File's height in pixels, if File is an image
58
+ * @var int
59
+ */
60
+ public $height;
61
+
62
+ /**
63
+ * File's width in pixels, if File is an image
64
+ * @var int
65
+ */
66
+ public $width;
67
+
68
+ /**
69
+ * File's size in bytes
70
+ * @var int
71
+ */
72
+ public $size;
73
+
74
+ /**
75
+ * URL of the image hosted by Constant Contact
76
+ * @var String
77
+ */
78
+ public $url;
79
+
80
+ /**
81
+ * Source of the image, must be one of "ALL", "MY_COMPUTER", "STOCK_IMAGE", "FACEBOOK", "INSTAGRAM", "SHUTTERSTOCK", "MOBILE"
82
+ * @var String
83
+ */
84
+ public $source;
85
+
86
+ /**
87
+ * Status of the file, must be one of "ACTIVE", "PROCESSING", "UPLOADED", "VIRUS_FOUND", "FAILED", "DELETED"
88
+ * @var String
89
+ */
90
+ public $status;
91
+
92
+ /**
93
+ * Thumbnail of the file, if File is an image
94
+ * @var Thumbnail
95
+ */
96
+ public $thumbnail;
97
+
98
+ /**
99
+ * Date the file was created, in ISO-8601 format
100
+ * @var String
101
+ */
102
+ public $created_date;
103
+
104
+ /**
105
+ * Date the file was last modified, in ISO-8601 format
106
+ * @var String
107
+ */
108
+ public $modified_date;
109
+
110
+ /**
111
+ * The file's type. (PNG, JPEG, PDF, etc.)
112
+ * @var String
113
+ */
114
+ public $file_type;
115
+
116
+ public static function create(array $props) {
117
+ $file = new File();
118
+
119
+ $file->id = parent::getValue($props, "id");
120
+ $file->name = parent::getValue($props, "name");
121
+ $file->description = parent::getValue($props, "description");
122
+ $file->folder = parent::getValue($props, "folder");
123
+ $file->folder_id = parent::getValue($props, "folder_id");
124
+ $file->is_image = parent::getValue($props, "is_image");
125
+ $file->type = parent::getValue($props, "file_type");
126
+ $file->height = parent::getValue($props, "height");
127
+ $file->width = parent::getValue($props, "width");
128
+ $file->size = parent::getValue($props, "size");
129
+ $file->url = parent::getValue($props, "url");
130
+ $file->source = parent::getValue($props, "source");
131
+ $file->status = parent::getValue($props, "status");
132
+ if (array_key_exists("thumbnail", $props)) {
133
+ $file->thumbnail = Thumbnail::create($props['thumbnail']);
134
+ }
135
+ $file->created_date = parent::getValue($props, "created_date");
136
+ $file->modified_date = parent::getValue($props, "modified_date");
137
+ $file->file_type = parent::getValue($props, "file_type");
138
+
139
+ return $file;
140
+ }
141
+
142
+ /**
143
+ * Create json used for a POST/PUT request, also handles removing attributes that will cause errors if sent
144
+ * @return String
145
+ */
146
+ public function toJson() {
147
+ unset($this->created_date);
148
+ unset($this->modified_date);
149
+ unset($this->status);
150
+ return json_encode($this);
151
+ }
152
+ }
app/api/Ctct/Components/Library/FileUploadStatus.php ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Ctct\Components\Library;
4
+
5
+ use Ctct\Components\Component;
6
+
7
+ /**
8
+ * Represents the status of a file upload in the Constant Contact Library
9
+ *
10
+ * @package Components
11
+ * @subpackage Library
12
+ * @author Constant Contact
13
+ */
14
+ class FileUploadStatus extends Component {
15
+ /**
16
+ * Detailed information about the upload status
17
+ * @var String
18
+ */
19
+ public $description;
20
+
21
+ /**
22
+ * Unique ID for the File
23
+ * @var String
24
+ */
25
+ public $file_id;
26
+
27
+ /**
28
+ * Indicates the file status.
29
+ * Will be one of: Active, Processing, Uploaded, VirusFound, Failed, Deleted
30
+ * @var String
31
+ */
32
+ public $status;
33
+
34
+ public static function create(Array $props) {
35
+ $fileUploadStatus = new FileUploadStatus();
36
+
37
+ $fileUploadStatus->description = parent::getValue($props, "description");
38
+ $fileUploadStatus->file_id = parent::getValue($props, "file_id");
39
+ $fileUploadStatus->status = parent::getValue($props, "status");
40
+
41
+ return $fileUploadStatus;
42
+ }
43
+ }
app/api/Ctct/Components/Library/Folder.php ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Ctct\Components\Library;
3
+
4
+ use Ctct\Components\Component;
5
+
6
+ class Folder extends Component {
7
+ /**
8
+ * ID of the Folder
9
+ * @var String
10
+ */
11
+ public $id;
12
+
13
+ /**
14
+ * Name of the Folder
15
+ * @var String
16
+ */
17
+ public $name;
18
+
19
+ /**
20
+ * Array of Folders that are children of this folder
21
+ * @var Folder[]
22
+ */
23
+ public $children;
24
+
25
+ /**
26
+ * Number of items in this folder
27
+ * @var int
28
+ */
29
+ public $item_count;
30
+
31
+ /**
32
+ * ID of this folder's parent, if there is one
33
+ * @var String
34
+ */
35
+ public $parent_id;
36
+
37
+ /**
38
+ * Depth that this folder is in the hierarchy, must be 1, 2, or 3
39
+ * @var int
40
+ */
41
+ public $level;
42
+
43
+ /**
44
+ * Date and time the folder was created
45
+ * @var String
46
+ */
47
+ public $created_date;
48
+
49
+ /**
50
+ * Date and time the folder was last modified
51
+ * @var String
52
+ */
53
+ public $modified_date;
54
+
55
+ public static function create(array $props) {
56
+ $folder = new Folder();
57
+
58
+ $folder->id = parent::getValue($props, "id");
59
+ $folder->name = parent::getValue($props, "name");
60
+ foreach ($props['children'] as $child) {
61
+ $folder->children[] = Folder::create($child);
62
+ }
63
+ $folder->item_count = parent::getValue($props, "item_count");
64
+ $folder->parent_id = parent::getValue($props, "parent_id");
65
+ $folder->level = parent::getValue($props, "level");
66
+ $folder->created_date = parent::getValue($props, "created_date");
67
+ $folder->modified_date = parent::getValue($props, "modified_date");
68
+
69
+ return $folder;
70
+ }
71
+
72
+ public function toJson() {
73
+ return json_encode($this);
74
+ }
75
+ }
app/api/Ctct/Components/Library/Thumbnail.php ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Ctct\Components\Library;
3
+
4
+ use Ctct\Components\Component;
5
+
6
+ /**
7
+ * Represents a Thumbnail of a File
8
+ *
9
+ * @package Components
10
+ * @subpackage Library
11
+ * @author Constant Contact
12
+ */
13
+ class Thumbnail extends Component {
14
+ /**
15
+ * URL to the thumbnail hosted by Constant Contact
16
+ * @var String
17
+ */
18
+ public $url;
19
+
20
+ /**
21
+ * Width of the thumbnail, in pixels
22
+ * @var int
23
+ */
24
+ public $width;
25
+
26
+ /**
27
+ * Height of the thumbnail, in pixels
28
+ * @var int
29
+ */
30
+ public $height;
31
+
32
+ public static function create(array $props) {
33
+ $thumbnail = new Thumbnail();
34
+
35
+ $thumbnail->url = parent::getValue($props, "url");
36
+ $thumbnail->width = parent::getValue($props, "width");
37
+ $thumbnail->height = parent::getValue($props, "height");
38
+
39
+ return $thumbnail;
40
+ }
41
+ }
app/api/Ctct/Components/ResultSet.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Ctct\Components;
3
+
4
+ /**
5
+ * Container for a get on a collection, such as Contacts, Campaigns, or TrackingData.
6
+ *
7
+ */
8
+ class ResultSet {
9
+ /**
10
+ * array of result objects returned
11
+ * @var array
12
+ */
13
+ public $results = array();
14
+
15
+ /**
16
+ * next link returned from a get on a collection if one exists
17
+ * @var string
18
+ */
19
+ public $next;
20
+
21
+ /**
22
+ * Constructor to create a ResultSet from the results/meta response when performing a get on a collection
23
+ * @param array $results - results array from request
24
+ * @param array $meta - meta array from request
25
+ */
26
+ public function __construct(array $results, array $meta) {
27
+ $this->results = $results;
28
+
29
+ if (array_key_exists('next_link', $meta['pagination'])) {
30
+ $nextLink = $meta['pagination']['next_link'];
31
+ $this->next = substr($nextLink, strpos($nextLink, '?') + 6);
32
+ }
33
+ }
34
+ }
app/api/Ctct/Components/Tracking/BounceActivity.php ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Ctct\Components\Tracking;
3
+
4
+ use Ctct\Components\Component;
5
+
6
+ /**
7
+ * Represents a single Bounce Activity
8
+ *
9
+ * @package Components
10
+ * @subpackage CampaignTracking
11
+ * @author Constant Contact
12
+ */
13
+ class BounceActivity extends Component {
14
+ public $activity_type;
15
+ public $bounce_code;
16
+ public $bounce_description;
17
+ public $bounce_message;
18
+ public $bounce_date;
19
+ public $contact_id;
20
+ public $email_address;
21
+ public $campaign_id;
22
+
23
+ /**
24
+ * Factory method to create a BounceActivity object from an array
25
+ * @param array $props - array of properties to create object from
26
+ * @return BounceActivity
27
+ */
28
+ public static function create(array $props) {
29
+ $bounceActivity = new BounceActivity();
30
+ $bounceActivity->activity_type = parent::getValue($props, "activity_type");
31
+ $bounceActivity->bounce_code = parent::getValue($props, "bounce_code");
32
+ $bounceActivity->bounce_description = parent::getValue($props, "bounce_description");
33
+ $bounceActivity->bounce_message = parent::getValue($props, "bounce_message");
34
+ $bounceActivity->bounce_date = parent::getValue($props, "bounce_date");
35
+ $bounceActivity->contact_id = parent::getValue($props, "contact_id");
36
+ $bounceActivity->email_address = parent::getValue($props, "email_address");
37
+ $bounceActivity->campaign_id = parent::getValue($props, "campaign_id");
38
+ return $bounceActivity;
39
+ }
40
+ }
app/api/Ctct/Components/Tracking/ClickActivity.php ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Ctct\Components\Tracking;
3
+
4
+ use Ctct\Components\Component;
5
+
6
+ /**
7
+ * Represents a Click Activity
8
+ *
9
+ * @package Components
10
+ * @subpackage CampaignTracking
11
+ * @author Constant Contact
12
+ */
13
+ class ClickActivity extends Component {
14
+ public $activity_type;
15
+ public $campaign_id;
16
+ public $contact_id;
17
+ public $email_address;
18
+ public $link_id;
19
+ public $click_date;
20
+
21
+ /**
22
+ * Factory method to create a ClickActivity object from an array
23
+ * @param array $props - array of properties to create object from
24
+ * @return ClickActivity
25
+ */
26
+ public static function create(array $props) {
27
+ $click_activity = new ClickActivity();
28
+ $click_activity->activity_type = parent::getValue($props, "activity_type");
29
+ $click_activity->campaign_id = parent::getValue($props, "campaign_id");
30
+ $click_activity->contact_id = parent::getValue($props, "contact_id");
31
+ $click_activity->email_address = parent::getValue($props, "email_address");
32
+ $click_activity->link_id = parent::getValue($props, "link_id");
33
+ $click_activity->click_date = parent::getValue($props, "click_date");
34
+ return $click_activity;
35
+ }
36
+ }
app/api/Ctct/Components/Tracking/ForwardActivity.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Ctct\Components\Tracking;
3
+
4
+ use Ctct\Components\Component;
5
+
6
+ /**
7
+ * Represents a Forward Activity
8
+ *
9
+ * @package Components
10
+ * @subpackage CampaignTracking
11
+ * @author Constant Contact
12
+ */
13
+ class ForwardActivity extends Component {
14
+ public $activity_type;
15
+ public $campaign_id;
16
+ public $contact_id;
17
+ public $email_address;
18
+ public $forward_date;
19
+
20
+ /**
21
+ * Factory method to create a ForwardActivity object from an array
22
+ * @param array $props - array of properties to create object from
23
+ * @return ForwardActivity
24
+ */
25
+ public static function create(array $props) {
26
+ $forward_activity = new ForwardActivity();
27
+ $forward_activity->activity_type = parent::getValue($props, "activity_type");
28
+ $forward_activity->campaign_id = parent::getValue($props, "campaign_id");
29
+ $forward_activity->contact_id = parent::getValue($props, "contact_id");
30
+ $forward_activity->email_address = parent::getValue($props, "email_address");
31
+ $forward_activity->forward_date = parent::getValue($props, "forward_date");
32
+
33
+ return $forward_activity;
34
+ }
35
+ }
app/api/Ctct/Components/Tracking/OpenActivity.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Ctct\Components\Tracking;
4
+
5
+ use Ctct\Components\Component;
6
+
7
+ /**
8
+ * Represents an Open Activity
9
+ *
10
+ * @package Components
11
+ * @subpackage CampaignTracking
12
+ * @author Constant Contact
13
+ */
14
+ class OpenActivity extends Component {
15
+ public $activity_type;
16
+ public $open_date;
17
+ public $contact_id;
18
+ public $email_address;
19
+ public $campaign_id;
20
+
21
+ /**
22
+ * Factory method to create a OpenActivity object from an array
23
+ * @param array $props - array of properties to create object from
24
+ * @return OpenActivity
25
+ */
26
+ public static function create(array $props) {
27
+ $open_activity = new OpenActivity();
28
+ $open_activity->activity_type = parent::getValue($props, "activity_type");
29
+ $open_activity->open_date = parent::getValue($props, "open_date");
30
+ $open_activity->contact_id = parent::getValue($props, "contact_id");
31
+ $open_activity->email_address = parent::getValue($props, "email_address");
32
+ $open_activity->campaign_id = parent::getValue($props, "campaign_id");
33
+ return $open_activity;
34
+ }
35
+ }
app/api/Ctct/Components/Tracking/SendActivity.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Ctct\Components\Tracking;
3
+
4
+ use Ctct\Components\Component;
5
+
6
+ /**
7
+ * Represents a Sent Activity
8
+ *
9
+ * @package Components
10
+ * @subpackage CampaignTracking
11
+ * @author Constant Contact
12
+ */
13
+ class SendActivity extends Component {
14
+ public $activity_type;
15
+ public $send_date;
16
+ public $contact_id;
17
+ public $email_address;
18
+ public $campaign_id;
19
+
20
+ /**
21
+ * Factory method to create a SentActivity object from an array
22
+ * @param array $props - array of properties to create object from
23
+ * @return SendActivity
24
+ */
25
+ public static function create(array $props) {
26
+ $sent_activity = new SendActivity();
27
+ $sent_activity->activity_type = parent::getValue($props, "activity_type");
28
+ $sent_activity->send_date = parent::getValue($props, "send_date");
29
+ $sent_activity->contact_id = parent::getValue($props, "contact_id");
30
+ $sent_activity->email_address = parent::getValue($props, "email_address");
31
+ $sent_activity->campaign_id = parent::getValue($props, "campaign_id");
32
+ return $sent_activity;
33
+ }
34
+ }
app/api/Ctct/Components/Tracking/TrackingActivity.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Ctct\Components\Tracking;
3
+
4
+ /**
5
+ * Class to wrap a result set of individual activities (ie: OpensActivity, SendActivity)
6
+ *
7
+ * @package Components
8
+ * @subpackage CampaignTracking
9
+ * @author Constant Contact
10
+ */
11
+ class TrackingActivity {
12
+ public $results = array();
13
+ public $next;
14
+
15
+ /**
16
+ * Constructor to create a TrackingActivity from the results/pagination response from getting a set of activities
17
+ * @param array $results - results array from a tracking endpoint
18
+ * @param array $pagination - pagination array returned from a tracking endpoint
19
+ */
20
+ public function __construct(array $results, array $pagination) {
21
+ $this->results = $results;
22
+
23
+ if (array_key_exists('next', $pagination)) {
24
+ $this->next = substr($pagination['next'], strrpos($pagination['next'], '&next=') + 6);
25
+ }
26
+ }
27
+ }
app/api/Ctct/Components/Tracking/TrackingSummary.php ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Ctct\Components\Tracking;
3
+
4
+ use Ctct\Components\Component;
5
+
6
+ /**
7
+ * Represents a Tracking Summary
8
+ *
9
+ * @package Components
10
+ * @subpackage Campaigns
11
+ * @author Constant Contact
12
+ */
13
+ class TrackingSummary extends Component {
14
+ public $sends;
15
+ public $opens;
16
+ public $clicks;
17
+ public $forwards;
18
+ public $unsubscribes;
19
+ public $bounces;
20
+ public $spam_count;
21
+
22
+ /**
23
+ * Factory method to create a TrackingSummary object from an array
24
+ * @param array $props - array of properties to create object from
25
+ * @return TrackingSummary
26
+ */
27
+ public static function create(array $props) {
28
+ $tracking_summary = new TrackingSummary();
29
+ $tracking_summary->sends = parent::getValue($props, "sends");
30
+ $tracking_summary->opens = parent::getValue($props, "opens");
31
+ $tracking_summary->clicks = parent::getValue($props, "clicks");
32
+ $tracking_summary->forwards = parent::getValue($props, "forwards");
33
+ $tracking_summary->unsubscribes = parent::getValue($props, "unsubscribes");
34
+ $tracking_summary->bounces = parent::getValue($props, "bounces");
35
+ $tracking_summary->spam_count = parent::getValue($props, "spam_count");
36
+
37
+ // Contacts don't have spam_count, only Campaigns
38
+ if (is_null($tracking_summary->spam_count)) {
39
+ unset($tracking_summary->spam_count);
40
+ }
41
+
42
+ return $tracking_summary;
43
+ }
44
+ }
app/api/Ctct/Components/Tracking/UnsubscribeActivity.php ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Ctct\Components\Tracking;
3
+
4
+ use Ctct\Components\Component;
5
+
6
+ /**
7
+ * Represents a single Opt Out Activity
8
+ *
9
+ * @package Components
10
+ * @subpackage CampaignTracking
11
+ * @author Constant Contact
12
+ */
13
+ class UnsubscribeActivity extends Component {
14
+ public $activity_type;
15
+ public $campaign_id;
16
+ public $contact_id;
17
+ public $email_address;
18
+ public $unsubscribe_date;
19
+ public $unsubscribe_source;
20
+ public $unsubscribe_reason;
21
+
22
+ /**
23
+ * Factory method to create an OptOutActivity object from an array
24
+ * @param array $props - array of properties to create object from
25
+ * @return UnsubscribeActivity
26
+ */
27
+ public static function create(array $props) {
28
+ $opt_out_activity = new UnsubscribeActivity();
29
+ $opt_out_activity->activity_type = parent::getValue($props, "activity_type");
30
+ $opt_out_activity->unsubscribe_date = parent::getValue($props, "unsubscribe_date");
31
+ $opt_out_activity->unsubscribe_source = parent::getValue($props, "unsubscribe_source");
32
+ $opt_out_activity->unsubscribe_reason = parent::getValue($props, "unsubscribe_reason");
33
+ $opt_out_activity->contact_id = parent::getValue($props, "contact_id");
34
+ $opt_out_activity->email_address = parent::getValue($props, "email_address");
35
+ $opt_out_activity->campaign_id = parent::getValue($props, "campaign_id");
36
+ return $opt_out_activity;
37
+ }
38
+ }
app/api/Ctct/ConstantContact.php ADDED
@@ -0,0 +1,98 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Ctct;
3
+
4
+ use Ctct\Services\AccountService;
5
+ use Ctct\Services\ActivityService;
6
+ use Ctct\Services\CampaignScheduleService;
7
+ use Ctct\Services\CampaignTrackingService;
8
+ use Ctct\Services\ContactService;
9
+ use Ctct\Services\ContactTrackingService;
10
+ use Ctct\Services\EmailMarketingService;
11
+ use Ctct\Services\LibraryService;
12
+ use Ctct\Services\ListService;
13
+ use GuzzleHttp\Client;
14
+ use GuzzleHttp\ClientInterface;
15
+
16
+ /**
17
+ * Exposes all implemented Constant Contact API functionality
18
+ *
19
+ * @package Ctct
20
+ * @version 2.0.0
21
+ * @author Constant Contact
22
+ * @link https://developer.constantcontact.com
23
+ */
24
+ class ConstantContact {
25
+ /**
26
+ * Handles interaction with contact management
27
+ * @var ContactService
28
+ */
29
+ public $contactService;
30
+
31
+ /**
32
+ * Handles interaction with email marketing
33
+ * @var EmailMarketingService
34
+ */
35
+ public $emailMarketingService;
36
+
37
+ /**
38
+ * Handles interaction with contact list management
39
+ * @var ListService
40
+ */
41
+ public $listService;
42
+
43
+ /**
44
+ * ActivityService for handling interaction with bulk activities
45
+ * @var ActivityService
46
+ */
47
+ public $activityService;
48
+
49
+ /**
50
+ * Handles interaction with email marketing tracking
51
+ * @var CampaignTrackingService
52
+ */
53
+ public $campaignTrackingService;
54
+
55
+ /**
56
+ * Handles interaction with contact tracking
57
+ * @var ContactTrackingService
58
+ */
59
+ public $contactTrackingService;
60
+
61
+ /**
62
+ * Handles interaction with email marketing campaign scheduling
63
+ * @var CampaignScheduleService
64
+ */
65
+ public $campaignScheduleService;
66
+
67
+ /**
68
+ * Handles interaction with account management
69
+ * @var AccountService
70
+ */
71
+ public $accountService;
72
+
73
+ /**
74
+ * Handles interaction with Library management
75
+ * @var LibraryService
76
+ */
77
+ public $libraryService;
78
+
79
+ /**
80
+ * Class constructor
81
+ * Registers the API key with the ConstantContact class that will be used for all API calls.
82
+ * @param string $apiKey - Constant Contact API Key
83
+ * @param ClientInterface|null $client - GuzzleHttp Client
84
+ */
85
+ public function __construct($apiKey, ClientInterface $client = null) {
86
+ $client = $client ?: new Client();
87
+
88
+ $this->contactService = new ContactService($apiKey, $client);
89
+ $this->emailMarketingService = new EmailMarketingService($apiKey, $client);
90
+ $this->activityService = new ActivityService($apiKey, $client);
91
+ $this->campaignTrackingService = new CampaignTrackingService($apiKey, $client);
92
+ $this->contactTrackingService = new ContactTrackingService($apiKey, $client);
93
+ $this->campaignScheduleService = new CampaignScheduleService($apiKey, $client);
94
+ $this->listService = new ListService($apiKey, $client);
95
+ $this->accountService = new AccountService($apiKey, $client);
96
+ $this->libraryService = new LibraryService($apiKey, $client);
97
+ }
98
+ }
app/api/Ctct/Exceptions/CtctException.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Ctct\Exceptions;
3
+
4
+ use Exception;
5
+
6
+ /**
7
+ * General exception
8
+ *
9
+ * @package exceptions
10
+ * @author djellesma
11
+ */
12
+ class CtctException extends Exception {
13
+ private $errors;
14
+
15
+ private $url;
16
+
17
+ public function getErrors() {
18
+ return $this->errors;
19
+ }
20
+
21
+ public function setErrors(array $errors) {
22
+ $this->errors = $errors;
23
+ }
24
+
25
+ public function setUrl($url) {
26
+ $this->url = $url;
27
+ }
28
+
29
+ public function getCurlInfo() {
30
+ return $this->url;
31
+ }
32
+ }
app/api/Ctct/Exceptions/IllegalArgumentException.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Ctct\Exceptions;
3
+
4
+ use Exception;
5
+
6
+ /**
7
+ * Exception thrown if there is an illegal argument passed to a particular method
8
+ *
9
+ * @package exceptions
10
+ * @author djellesma
11
+ */
12
+ class IllegalArgumentException extends Exception {
13
+ }
app/api/Ctct/Exceptions/OAuth2Exception.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Ctct\Exceptions;
3
+
4
+ /**
5
+ * Exception thrown if an error occurred during OAuth2 authentication process
6
+ *
7
+ * @package exceptions
8
+ * @author djellesma
9
+ */
10
+ class OAuth2Exception extends CtctException {
11
+ }
app/api/Ctct/Services/AccountService.php ADDED
@@ -0,0 +1,111 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Ctct\Services;
3
+
4
+ use Ctct\Components\Account\AccountInfo;
5
+ use Ctct\Components\Account\VerifiedEmailAddress;
6
+ use Ctct\Exceptions\CtctException;
7
+ use Ctct\Util\Config;
8
+ use GuzzleHttp\Exception\TransferException;
9
+ use GuzzleHttp\Psr7;
10
+
11
+ /**
12
+ * Performs all actions pertaining to scheduling Constant Contact Account's
13
+ *
14
+ * @package Services
15
+ * @author Constant Contact
16
+ */
17
+ class AccountService extends BaseService {
18
+ /**
19
+ * Get all verified email addresses associated with an account
20
+ * @param string $accessToken - Constant Contact OAuth2 Access Token
21
+ * @param array $params - associative array of query parameters and values to append to the request.
22
+ * Allowed parameters include:
23
+ * status - Status to filter results by. Must be one of ALL, CONFIRMED, or UNCONFIRMED.
24
+ * @return array of VerifiedEmailAddress
25
+ * @throws CtctException
26
+ */
27
+ public function getVerifiedEmailAddresses($accessToken, Array $params = array()) {
28
+ $baseUrl = Config::get('endpoints.base_url') . Config::get('endpoints.account_verified_addresses');
29
+ $request = parent::sendRequestWithoutBody($accessToken, 'GET', $baseUrl, $params);
30
+
31
+ try {
32
+ $response = parent::getClient()->send($request);
33
+ } catch (TransferException $e) {
34
+ throw parent::convertException($e);
35
+ }
36
+
37
+ $verifiedAddresses = array();
38
+ foreach (json_decode($response->getBody(), true) as $verifiedAddress) {
39
+ $verifiedAddresses[] = VerifiedEmailAddress::create($verifiedAddress);
40
+ }
41
+
42
+ return $verifiedAddresses;
43
+ }
44
+
45
+ /**
46
+ * Create a new verified email address. This will also prompt the account to send
47
+ * a verification email to the address.
48
+ * @param string $accessToken - Constant Contact OAuth2 Access Token
49
+ * @param string $emailAddress - email address to create
50
+ * @return array - array of VerifiedEmailAddress created
51
+ * @throws CtctException
52
+ */
53
+ public function createVerifiedEmailAddress($accessToken, $emailAddress) {
54
+ $baseUrl = Config::get('endpoints.base_url') . Config::get('endpoints.account_verified_addresses');
55
+ $request = parent::sendRequestWithBody($accessToken, 'POST', $baseUrl, array(array("email_address" => $emailAddress)));
56
+
57
+ try {
58
+ $response = parent::getClient()->send($request);
59
+ } catch (TransferException $e) {
60
+ throw parent::convertException($e);
61
+ }
62
+
63
+ $verifiedAddresses = array();
64
+ foreach (json_decode($response->getBody(), true) as $verifiedAddress) {
65
+ $verifiedAddresses[] = VerifiedEmailAddress::create($verifiedAddress);
66
+ }
67
+
68
+ return $verifiedAddresses;
69
+ }
70
+
71
+ /**
72
+ * Get account info associated with an access token
73
+ * @param string $accessToken - Constant Contact OAuth2 Access Token
74
+ * @return AccountInfo
75
+ * @throws CtctException
76
+ */
77
+ public function getAccountInfo($accessToken) {
78
+ $baseUrl = Config::get('endpoints.base_url') . Config::get('endpoints.account_info');
79
+
80
+ $request = parent::sendRequestWithoutBody($accessToken, 'GET', $baseUrl);
81
+
82
+ try {
83
+ $response = parent::getClient()->send($request);
84
+ } catch (TransferException $e) {
85
+ throw parent::convertException($e);
86
+ }
87
+
88
+ return AccountInfo::create(json_decode($response->getBody(), true));
89
+ }
90
+
91
+ /**
92
+ * Update information of the account.
93
+ * @param string $accessToken - Constant Contact OAuth2 Access Token
94
+ * @param AccountInfo $accountInfo - Updated AccountInfo
95
+ * @return AccountInfo
96
+ * @throws CtctException
97
+ */
98
+ public function updateAccountInfo($accessToken, AccountInfo $accountInfo) {
99
+ $baseUrl = Config::get('endpoints.base_url') . Config::get('endpoints.account_info');
100
+
101
+ $request = parent::sendRequestWithBody($accessToken, 'PUT', $baseUrl, $accountInfo);
102
+
103
+ try {
104
+ $response = parent::getClient()->send($request);
105
+ } catch (TransferException $e) {
106
+ throw parent::convertException($e);
107
+ }
108
+
109
+ return AccountInfo::create(json_decode($response->getBody(), true));
110
+ }
111
+ }
app/api/Ctct/Services/ActivityService.php ADDED
@@ -0,0 +1,213 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Ctct\Services;
3
+
4
+ use Ctct\Components\Activities\Activity;
5
+ use Ctct\Components\Activities\AddContacts;
6
+ use Ctct\Components\Activities\ExportContacts;
7
+ use Ctct\Exceptions\CtctException;
8
+ use Ctct\Util\Config;
9
+ use GuzzleHttp\Exception\TransferException;
10
+ use GuzzleHttp\Psr7\Request;
11
+
12
+ /**
13
+ * Performs all actions pertaining to scheduling Constant Contact Activities
14
+ *
15
+ * @package Services
16
+ * @author ConstantContact
17
+ */
18
+ class ActivityService extends BaseService {
19
+ /**
20
+ * Get an array of activities
21
+ * @param string $accessToken - Constant Contact OAuth2 access token
22
+ * @param array $params - associative array of query parameters and values to append to the request.
23
+ * Allowed parameters include:
24
+ * status - Status of the activity, must be one of UNCONFIRMED, PENDING, QUEUED, RUNNING, COMPLETE, ERROR
25
+ * type - Type of activity, must be one of ADD_CONTACTS, REMOVE_CONTACTS_FROM_LISTS, CLEAR_CONTACTS_FROM_LISTS,
26
+ * EXPORT_CONTACTS
27
+ * @return array - Array of all ActivitySummaryReports
28
+ * @throws CtctException
29
+ */
30
+ public function getActivities($accessToken, Array $params = array()) {
31
+ $baseUrl = Config::get('endpoints.base_url') . Config::get('endpoints.activities');
32
+
33
+ try {
34
+ $response = parent::sendRequestWithoutBody($accessToken, 'GET', $baseUrl, $params);
35
+ } catch (TransferException $e) {
36
+ throw parent::convertException($e);
37
+ }
38
+
39
+ $activities = array();
40
+ foreach (json_decode($response->getBody(), true) as $activity) {
41
+ $activities[] = Activity::create($activity);
42
+ }
43
+ return $activities;
44
+ }
45
+
46
+ /**
47
+ * Get an array of activities
48
+ * @param string $accessToken - Constant Contact OAuth2 access token
49
+ * @param string $activityId - Activity id
50
+ * @return array - Array of all ActivitySummaryReports
51
+ * @throws CtctException
52
+ */
53
+ public function getActivity($accessToken, $activityId) {
54
+ $baseUrl = Config::get('endpoints.base_url') . sprintf(Config::get('endpoints.activity'), $activityId);
55
+
56
+ try {
57
+ $response = parent::sendRequestWithoutBody($accessToken, 'GET', $baseUrl);
58
+ } catch (TransferException $e) {
59
+ throw parent::convertException($e);
60
+ }
61
+
62
+ return Activity::create(json_decode($response->getBody(), true));
63
+ }
64
+
65
+ /**
66
+ * Create an Add Contacts Activity
67
+ * @param string $accessToken - Constant Contact OAuth2 access token
68
+ * @param AddContacts $addContacts
69
+ * @return array - Array of all ActivitySummaryReports
70
+ * @throws CtctException
71
+ */
72
+ public function createAddContactsActivity($accessToken, AddContacts $addContacts) {
73
+ $baseUrl = Config::get('endpoints.base_url') . Config::get('endpoints.add_contacts_activity');
74
+
75
+ try {
76
+ $response = parent::sendRequestWithBody($accessToken, 'POST', $baseUrl, $addContacts);
77
+ } catch (TransferException $e) {
78
+ throw parent::convertException($e);
79
+ }
80
+
81
+ return Activity::create(json_decode($response->getBody(), true));
82
+ }
83
+
84
+ /**
85
+ * Create an Add Contacts Activity from a file. Valid file types are txt, csv, xls, xlsx
86
+ * @param string $accessToken - Constant Contact OAuth2 access token
87
+ * @param string $fileName - The name of the file (ie: contacts.csv)
88
+ * @param string $fileLocation - The location of the file on the server, this method uses fopen()
89
+ * @param string $lists - Comma separated list of ContactList id's to add the contacts to
90
+ * @return Activity
91
+ * @throws CtctException
92
+ */
93
+ public function createAddContactsActivityFromFile($accessToken, $fileName, $fileLocation, $lists) {
94
+ $baseUrl = Config::get('endpoints.base_url') . Config::get('endpoints.add_contacts_activity');
95
+ $request = new Request('POST', $baseUrl, [
96
+ parent::getHeadersForMultipart($accessToken)
97
+ ]);
98
+
99
+ try {
100
+ $response = $this->getClient()->send($request, [
101
+ 'multipart' => [
102
+ [
103
+ 'lists' => $lists,
104
+ 'file_name' => $fileName,
105
+ 'data' => fopen($fileLocation, 'r')
106
+ ]
107
+ ]
108
+ ]);
109
+ } catch (TransferException $e) {
110
+ throw parent::convertException($e);
111
+ }
112
+
113
+ return Activity::create(json_decode($response->getBody(), true));
114
+ }
115
+
116
+ /**
117
+ * Create a clear lists activity. This removes all contacts on the selected lists while keeping
118
+ * the list itself intact.
119
+ * @param $accessToken - Constant Contact OAuth2 access token
120
+ * @param array $lists - Array of list ID's to be cleared
121
+ * @return Activity
122
+ * @throws CtctException
123
+ */
124
+ public function addClearListsActivity($accessToken, Array $lists) {
125
+ $baseUrl = Config::get('endpoints.base_url') . Config::get('endpoints.clear_lists_activity');
126
+
127
+ try {
128
+ $response = parent::sendRequestWithBody($accessToken, "POST", $baseUrl, array("lists" => $lists));
129
+ } catch (TransferException $e) {
130
+ throw parent::convertException($e);
131
+ }
132
+
133
+ return Activity::create(json_decode($response->getBody(), true));
134
+ }
135
+
136
+ /**
137
+ * Create an Export Contacts Activity
138
+ * @param string $accessToken - Constant Contact OAuth2 access token
139
+ * @param ExportContacts $exportContacts
140
+ * @return array - Array of all ActivitySummaryReports
141
+ * @throws CtctException
142
+ */
143
+ public function addExportContactsActivity($accessToken, ExportContacts $exportContacts) {
144
+ $baseUrl = Config::get('endpoints.base_url') . Config::get('endpoints.export_contacts_activity');
145
+
146
+ try {
147
+ $response = parent::sendRequestWithBody($accessToken, 'POST', $baseUrl, $exportContacts);
148
+ } catch (TransferException $e) {
149
+ throw parent::convertException($e);
150
+ }
151
+
152
+ return Activity::create(json_decode($response->getBody(), true));
153
+ }
154
+
155
+ /**
156
+ * Create a Remove Contacts from Lists Activity
157
+ * @param $accessToken - Constant Contact OAuth2 access token
158
+ * @param array $emailAddresses - array of email addresses to remove
159
+ * @param array $lists - array of list ID's to remove the provided email addresses from
160
+ * @return Activity
161
+ * @throws CtctException
162
+ */
163
+ public function addRemoveContactsFromListsActivity($accessToken, Array $emailAddresses, Array $lists) {
164
+ $baseUrl = Config::get('endpoints.base_url') . Config::get('endpoints.remove_from_lists_activity');
165
+ $payload = array(
166
+ 'import_data' => array(),
167
+ 'lists' => $lists
168
+ );
169
+ foreach ($emailAddresses as $emailAddress) {
170
+ $payload['import_data'][] = array('email_addresses' => array($emailAddress));
171
+ }
172
+
173
+ try {
174
+ $response = parent::sendRequestWithBody($accessToken, "POST", $baseUrl, $payload);
175
+ } catch (TransferException $e) {
176
+ throw parent::convertException($e);
177
+ }
178
+
179
+ return Activity::create(json_decode($response->getBody(), true));
180
+ }
181
+
182
+ /**
183
+ * Create a Remove Contacts Activity from a file. Valid file types are txt, csv, xls, xlsx
184
+ * @param string $accessToken - Constant Contact OAuth2 access token
185
+ * @param string $fileName - The name of the file (ie: contacts.csv)
186
+ * @param string $fileLocation - The location of the file on the server, this method uses fopen()
187
+ * @param string $lists - Comma separated list of ContactList id's to add the contacts to
188
+ * @return Activity
189
+ * @throws CtctException
190
+ */
191
+ public function addRemoveContactsFromListsActivityFromFile($accessToken, $fileName, $fileLocation, $lists) {
192
+ $baseUrl = Config::get('endpoints.base_url') . Config::get('endpoints.remove_from_lists_activity');
193
+ $request = new Request('POST', $baseUrl, [
194
+ parent::getHeadersForMultipart($accessToken)
195
+ ]);
196
+
197
+ try {
198
+ $response = $this->getClient()->send($request, [
199
+ 'multipart' => [
200
+ [
201
+ 'lists' => $lists,
202
+ 'file_name' => $fileName,
203
+ 'data' => fopen($fileLocation, 'r')
204
+ ]
205
+ ]
206
+ ]);;
207
+ } catch (TransferException $e) {
208
+ throw parent::convertException($e);
209
+ }
210
+
211
+ return Activity::create(json_decode($response->getBody(), true));
212
+ }
213
+ }
app/api/Ctct/Services/BaseService.php ADDED
@@ -0,0 +1,108 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Ctct\Services;
3
+
4
+ use Ctct\Exceptions\CtctException;
5
+ use Ctct\Util\Config;
6
+ use GuzzleHttp\Client;
7
+ use GuzzleHttp\ClientInterface;
8
+ use GuzzleHttp\Exception\ClientException;
9
+ use GuzzleHttp\Exception\ServerException;
10
+ use GuzzleHttp\Exception\TransferException;
11
+ use GuzzleHttp\Psr7\Request;
12
+
13
+ /**
14
+ * Super class for all services
15
+ *
16
+ * @package Services
17
+ * @author Constant Contact
18
+ */
19
+ abstract class BaseService {
20
+ /**
21
+ * GuzzleHTTP Client Implementation to use for HTTP requests
22
+ * @var Client
23
+ */
24
+ private $client;
25
+ /**
26
+ * ApiKey for the application
27
+ * @var string
28
+ */
29
+ private $apiKey;
30
+
31
+ /**
32
+ * Constructor with the option to to supply an alternative rest client to be used
33
+ * @param string $apiKey - Constant Contact API Key
34
+ * @param ClientInterface|null $client - GuzzleHttp Client
35
+ */
36
+ public function __construct($apiKey, ClientInterface $client = null) {
37
+ $this->apiKey = $apiKey;
38
+ $this->client = $client ?: new Client();
39
+ }
40
+
41
+ protected static function getHeadersForMultipart($accessToken) {
42
+ return array(
43
+ 'User-Agent' => 'ConstantContact AppConnect PHP Library v' . Config::get('settings.version'),
44
+ 'Content-Type' => 'multipart/form-data',
45
+ 'Authorization' => 'Bearer ' . $accessToken
46
+ );
47
+ }
48
+
49
+ /**
50
+ * Get the rest client being used by the service
51
+ * @return Client - GuzzleHTTP Client implementation being used
52
+ */
53
+ protected function getClient() {
54
+ return $this->client;
55
+ }
56
+
57
+ protected function sendRequestWithBody($accessToken, $method, $baseUrl, $body, Array $queryParams = array()) {
58
+ $queryParams["api_key"] = $this->apiKey;
59
+ $request = new Request($method, $baseUrl);
60
+ return $this->client->send($request, [
61
+ 'query' => $queryParams,
62
+ 'json' => $body,
63
+ 'headers' => self::getHeaders($accessToken)
64
+ ]);
65
+ }
66
+
67
+ /**
68
+ * Helper function to return required headers for making an http request with constant contact
69
+ * @param $accessToken - OAuth2 access token to be placed into the Authorization header
70
+ * @return array - authorization headers
71
+ */
72
+ private static function getHeaders($accessToken) {
73
+ return array(
74
+ 'User-Agent' => 'ConstantContact AppConnect PHP Library v' . Config::get('settings.version'),
75
+ 'Content-Type' => 'application/json',
76
+ 'Accept' => 'application/json',
77
+ 'Authorization' => 'Bearer ' . $accessToken,
78
+ 'x-ctct-request-source' => 'sdk.php.' . Config::get('settings.version')
79
+ );
80
+ }
81
+
82
+ protected function sendRequestWithoutBody($accessToken, $method, $baseUrl, Array $queryParams = array()) {
83
+ $queryParams["api_key"] = $this->apiKey;
84
+ $request = new Request($method, $baseUrl);
85
+
86
+ return $this->client->send($request, [
87
+ 'query' => $queryParams,
88
+ 'headers' => self::getHeaders($accessToken)
89
+ ]);
90
+ }
91
+
92
+ /**
93
+ * Turns a ClientException into a CtctException - like magic.
94
+ * @param TransferException $exception - Guzzle TransferException can be one of RequestException,
95
+ * ConnectException, ClientException, ServerException
96
+ * @return CtctException
97
+ */
98
+ protected function convertException($exception) {
99
+ if ($exception instanceof ClientException || $exception instanceof ServerException) {
100
+ $ctctException = new CtctException($exception->getResponse()->getReasonPhrase(), $exception->getCode());
101
+ } else {
102
+ $ctctException = new CtctException("Something went wrong", $exception->getCode());
103
+ }
104
+ $ctctException->setUrl($exception->getRequest()->getUri());
105
+ $ctctException->setErrors(json_decode($exception->getResponse()->getBody()->getContents()));
106
+ return $ctctException;
107
+ }
108
+ }
app/api/Ctct/Services/CampaignScheduleService.php ADDED
@@ -0,0 +1,139 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Ctct\Services;
3
+
4
+ use Ctct\Components\EmailMarketing\Schedule;
5
+ use Ctct\Components\EmailMarketing\TestSend;
6
+ use Ctct\Exceptions\CtctException;
7
+ use Ctct\Util\Config;
8
+ use GuzzleHttp\Exception\TransferException;
9
+
10
+ /**
11
+ * Performs all actions pertaining to scheduling Constant Contact Campaigns
12
+ *
13
+ * @package Services
14
+ * @author Constant Contact
15
+ */
16
+ class CampaignScheduleService extends BaseService {
17
+ /**
18
+ * Create a new schedule for a campaign
19
+ * @param string $accessToken - Constant Contact OAuth2 access token
20
+ * @param int $campaignId - Campaign id to be scheduled
21
+ * @param Schedule $schedule - Schedule to be created
22
+ * @return Schedule
23
+ * @throws CtctException
24
+ */
25
+ public function addSchedule($accessToken, $campaignId, Schedule $schedule) {
26
+ $baseUrl = Config::get('endpoints.base_url') . sprintf(Config::get('endpoints.campaign_schedules'), $campaignId);
27
+
28
+ try {
29
+ $response = parent::sendRequestWithBody($accessToken, 'POST', $baseUrl, $schedule);
30
+ } catch (TransferException $e) {
31
+ throw parent::convertException($e);
32
+ }
33
+
34
+ return Schedule::create(json_decode($response->getBody(), true));
35
+ }
36
+
37
+ /**
38
+ * Get a list of schedules for a campaign
39
+ * @param string $accessToken - Constant Contact OAuth2 access token
40
+ * @param int $campaignId - Campaign id to be scheduled
41
+ * @return array
42
+ * @throws CtctException
43
+ */
44
+ public function getSchedules($accessToken, $campaignId) {
45
+ $baseUrl = Config::get('endpoints.base_url') . sprintf(Config::get('endpoints.campaign_schedules'), $campaignId);
46
+
47
+ try {
48
+ $response = parent::sendRequestWithoutBody($accessToken, 'GET', $baseUrl);
49
+ } catch (TransferException $e) {
50
+ throw parent::convertException($e);
51
+ }
52
+
53
+ $schedules = array();
54
+ foreach (json_decode($response->getBody(), true) as $schedule) {
55
+ $schedules[] = Schedule::create($schedule);
56
+ }
57
+ return $schedules;
58
+ }
59
+
60
+ /**
61
+ * Get a specific schedule for a campaign
62
+ * @param string $accessToken - Constant Contact OAuth2 access token
63
+ * @param int $campaignId - Campaign id to be get a schedule for
64
+ * @param int $scheduleId - Schedule id to retrieve
65
+ * @return Schedule
66
+ * @throws CtctException
67
+ */
68
+ public function getSchedule($accessToken, $campaignId, $scheduleId) {
69
+ $baseUrl = Config::get('endpoints.base_url') . sprintf(Config::get('endpoints.campaign_schedule'), $campaignId, $scheduleId);
70
+
71
+ try {
72
+ $response = parent::sendRequestWithoutBody($accessToken, 'GET', $baseUrl);
73
+ } catch (TransferException $e) {
74
+ throw parent::convertException($e);
75
+ }
76
+
77
+ return Schedule::create(json_decode($response->getBody(), true));
78
+ }
79
+
80
+ /**
81
+ * Update a specific schedule for a campaign
82
+ * @param string $accessToken - Constant Contact OAuth2 access token
83
+ * @param int $campaignId - Campaign id to be scheduled
84
+ * @param Schedule $schedule - Schedule to retrieve
85
+ * @return Schedule
86
+ * @throws CtctException
87
+ */
88
+ public function updateSchedule($accessToken, $campaignId, Schedule $schedule) {
89
+ $baseUrl = Config::get('endpoints.base_url') . sprintf(Config::get('endpoints.campaign_schedule'), $campaignId, $schedule->id);
90
+
91
+ try {
92
+ $response = parent::sendRequestWithBody($accessToken, 'PUT', $baseUrl, $schedule);
93
+ } catch (TransferException $e) {
94
+ throw parent::convertException($e);
95
+ }
96
+
97
+ return Schedule::create(json_decode($response->getBody(), true));
98
+ }
99
+
100
+ /**
101
+ * Delete a specific schedule for a campaign
102
+ * @param string $accessToken - Constant Contact OAuth2 access token
103
+ * @param int $campaignId - Campaign id
104
+ * @param int $scheduleId - Schedule id to delete
105
+ * @return True if successful
106
+ * @throws CtctException
107
+ */
108
+ public function deleteSchedule($accessToken, $campaignId, $scheduleId) {
109
+ $baseUrl = Config::get('endpoints.base_url') . sprintf(Config::get('endpoints.campaign_schedule'), $campaignId, $scheduleId);
110
+
111
+ try {
112
+ $response = parent::sendRequestWithoutBody($accessToken, 'DELETE', $baseUrl);
113
+ } catch (TransferException $e) {
114
+ throw parent::convertException($e);
115
+ }
116
+
117
+ return ($response->getStatusCode() == 204) ? true : false;
118
+ }
119
+
120
+ /**
121
+ * Send a test send of a campaign
122
+ * @param string $accessToken - Constant Contact OAuth2 access token
123
+ * @param int $campaignId - Id of campaign to send test of
124
+ * @param TestSend $testSend - Test send details
125
+ * @return TestSend
126
+ * @throws CtctException
127
+ */
128
+ public function sendTest($accessToken, $campaignId, TestSend $testSend) {
129
+ $baseUrl = Config::get('endpoints.base_url') . sprintf(Config::get('endpoints.campaign_test_sends'), $campaignId);
130
+
131
+ try {
132
+ $response = parent::sendRequestWithoutBody($accessToken, 'POST', $baseUrl, $testSend);
133
+ } catch (TransferException $e) {
134
+ throw parent::convertException($e);
135
+ }
136
+
137
+ return TestSend::create(json_decode($response->getBody(), true));
138
+ }
139
+ }
app/api/Ctct/Services/CampaignTrackingService.php ADDED
@@ -0,0 +1,221 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Ctct\Services;
3
+
4
+ use Ctct\Components\ResultSet;
5
+ use Ctct\Components\Tracking\BounceActivity;
6
+ use Ctct\Components\Tracking\ClickActivity;
7
+ use Ctct\Components\Tracking\ForwardActivity;
8
+ use Ctct\Components\Tracking\OpenActivity;
9
+ use Ctct\Components\Tracking\SendActivity;
10
+ use Ctct\Components\Tracking\TrackingActivity;
11
+ use Ctct\Components\Tracking\TrackingSummary;
12
+ use Ctct\Components\Tracking\UnsubscribeActivity;
13
+ use Ctct\Exceptions\CtctException;
14
+ use Ctct\Util\Config;
15
+ use GuzzleHttp\Exception\TransferException;
16
+
17
+ /**
18
+ * Performs all actions pertaining to Constant Contact Campaign Tracking
19
+ *
20
+ * @package Services
21
+ * @author Constant Contact
22
+ */
23
+ class CampaignTrackingService extends BaseService {
24
+ /**
25
+ * Get a result set of bounces for a given campaign
26
+ * @param string $accessToken - Constant Contact OAuth2 access token
27
+ * @param string $campaignId - Campaign id
28
+ * @param array $params - associative array of query parameters and values to append to the request.
29
+ * Allowed parameters include:
30
+ * limit - Specifies the number of results displayed per page of output, from 1 - 500, default = 50.
31
+ * created_since - Used to retrieve a list of events since the date and time specified (in ISO-8601 format).
32
+ * next - the next link returned from a previous paginated call. May only be used by itself.
33
+ * @return ResultSet - Containing a results array of {@link BounceActivity}
34
+ * @throws CtctException
35
+ */
36
+ public function getBounces($accessToken, $campaignId, Array $params = array()) {
37
+ $baseUrl = Config::get('endpoints.base_url') . sprintf(Config::get('endpoints.campaign_tracking_bounces'), $campaignId);
38
+
39
+ try {
40
+ $response = parent::sendRequestWithoutBody($accessToken, 'GET', $baseUrl, $params);
41
+ } catch (TransferException $e) {
42
+ throw parent::convertException($e);
43
+ }
44
+
45
+ $body = json_decode($response->getBody(), true);
46
+ $bounces = array();
47
+ foreach ($body['results'] as $bounceActivity) {
48
+ $bounces[] = BounceActivity::create($bounceActivity);
49
+ }
50
+ return new ResultSet($bounces, $body['meta']);
51
+ }
52
+
53
+ /**
54
+ * Get clicks for a given campaign
55
+ * @param string $accessToken - Constant Contact OAuth2 access token
56
+ * @param string $campaignId - Campaign id
57
+ * @param array $params - associative array of query parameters and values to append to the request.
58
+ * Allowed parameters include:
59
+ * limit - Specifies the number of results displayed per page of output, from 1 - 500, default = 50.
60
+ * created_since - Used to retrieve a list of events since the date and time specified (in ISO-8601 format).
61
+ * next - the next link returned from a previous paginated call. May only be used by itself.
62
+ * @return ResultSet - Containing a results array of {@link ClickActivity}
63
+ * @throws CtctException
64
+ */
65
+ public function getClicks($accessToken, $campaignId, Array $params = array()) {
66
+ $baseUrl = Config::get('endpoints.base_url') . sprintf(Config::get('endpoints.campaign_tracking_clicks'), $campaignId);
67
+
68
+ try {
69
+ $response = parent::sendRequestWithoutBody($accessToken, 'GET', $baseUrl, $params);
70
+ } catch (TransferException $e) {
71
+ throw parent::convertException($e);
72
+ }
73
+
74
+ $body = json_decode($response->getBody(), true);
75
+ $clicks = array();
76
+ foreach ($body['results'] as $click_activity) {
77
+ $clicks[] = ClickActivity::create($click_activity);
78
+ }
79
+
80
+ return new ResultSet($clicks, $body['meta']);
81
+ }
82
+
83
+ /**
84
+ * Get forwards for a given campaign
85
+ * @param string $accessToken - Constant Contact OAuth2 access token
86
+ * @param string $campaignId - Campaign id
87
+ * @param array $params - associative array of query parameters and values to append to the request.
88
+ * Allowed parameters include:
89
+ * limit - Specifies the number of results displayed per page of output, from 1 - 500, default = 50.
90
+ * created_since - Used to retrieve a list of events since the date and time specified (in ISO-8601 format).
91
+ * next - the next link returned from a previous paginated call. May only be used by itself.
92
+ * @return ResultSet - Containing a results array of {@link ForwardActivity}
93
+ * @throws CtctException
94
+ */
95
+ public function getForwards($accessToken, $campaignId, Array $params = array()) {
96
+ $baseUrl = Config::get('endpoints.base_url') . sprintf(Config::get('endpoints.campaign_tracking_forwards'), $campaignId);
97
+
98
+ try {
99
+ $response = parent::sendRequestWithoutBody($accessToken, 'GET', $baseUrl, $params);
100
+ } catch (TransferException $e) {
101
+ throw parent::convertException($e);
102
+ }
103
+
104
+ $body = json_decode($response->getBody(), true);
105
+ $forwards = array();
106
+ foreach ($body['results'] as $forward_activity) {
107
+ $forwards[] = ForwardActivity::create($forward_activity);
108
+ }
109
+
110
+ return new ResultSet($forwards, $body['meta']);
111
+ }
112
+
113
+ /**
114
+ * Get opens for a given campaign
115
+ * @param string $accessToken - Constant Contact OAuth2 access token
116
+ * @param string $campaignId - Campaign id
117
+ * @param array $params - associative array of query parameters and values to append to the request.
118
+ * Allowed parameters include:
119
+ * limit - Specifies the number of results displayed per page of output, from 1 - 500, default = 50.
120
+ * created_since - Used to retrieve a list of events since the date and time specified (in ISO-8601 format).
121
+ * next - the next link returned from a previous paginated call. May only be used by itself.
122
+ * @return ResultSet - Containing a results array of {@link OpenActivity}
123
+ * @throws CtctException
124
+ */
125
+ public function getOpens($accessToken, $campaignId, Array $params = array()) {
126
+ $baseUrl = Config::get('endpoints.base_url') . sprintf(Config::get('endpoints.campaign_tracking_opens'), $campaignId);
127
+
128
+ try {
129
+ $response = parent::sendRequestWithoutBody($accessToken, 'GET', $baseUrl, $params);
130
+ } catch (TransferException $e) {
131
+ throw parent::convertException($e);
132
+ }
133
+
134
+ $body = json_decode($response->getBody(), true);
135
+ $opens = array();
136
+ foreach ($body['results'] as $open_activity) {
137
+ $opens[] = OpenActivity::create($open_activity);
138
+ }
139
+
140
+ return new ResultSet($opens, $body['meta']);
141
+ }
142
+
143
+ /**
144
+ * Get sends for a given campaign
145
+ * @param string $accessToken - Constant Contact OAuth2 access token
146
+ * @param string $campaignId - Campaign id
147
+ * @param array $params - associative array of query parameters and values to append to the request.
148
+ * Allowed parameters include:
149
+ * limit - Specifies the number of results displayed per page of output, from 1 - 500, default = 50.
150
+ * created_since - Used to retrieve a list of events since the date and time specified (in ISO-8601 format).
151
+ * next - the next link returned from a previous paginated call. May only be used by itself.
152
+ * @return TrackingActivity - Containing a results array of {@link SendActivity}
153
+ * @throws CtctException
154
+ */
155
+ public function getSends($accessToken, $campaignId, Array $params = array()) {
156
+ $baseUrl = Config::get('endpoints.base_url') . sprintf(Config::get('endpoints.campaign_tracking_sends'), $campaignId);
157
+
158
+ try {
159
+ $response = parent::sendRequestWithoutBody($accessToken, 'GET', $baseUrl, $params);
160
+ } catch (TransferException $e) {
161
+ throw parent::convertException($e);
162
+ }
163
+
164
+ $body = json_decode($response->getBody(), true);
165
+ $sends = array();
166
+ foreach ($body['results'] as $send_activity) {
167
+ $sends[] = SendActivity::create($send_activity);
168
+ }
169
+
170
+ return new ResultSet($sends, $body['meta']);
171
+ }
172
+
173
+ /**
174
+ * Get unsubscribes for a given campaign
175
+ * @param string $accessToken - Constant Contact OAuth2 access token
176
+ * @param string $campaignId - Campaign id
177
+ * @param array $params - associative array of query parameters and values to append to the request.
178
+ * Allowed parameters include:
179
+ * limit - Specifies the number of results displayed per page of output, from 1 - 500, default = 50.
180
+ * created_since - Used to retrieve a list of events since the date and time specified (in ISO-8601 format).
181
+ * next - the next link returned from a previous paginated call. May only be used by itself.
182
+ * @return ResultSet - Containing a results array of {@link UnsubscribeActivity}
183
+ * @throws CtctException
184
+ */
185
+ public function getUnsubscribes($accessToken, $campaignId, Array $params = array()) {
186
+ $baseUrl = Config::get('endpoints.base_url') . sprintf(Config::get('endpoints.campaign_tracking_unsubscribes'), $campaignId);
187
+
188
+ try {
189
+ $response = parent::sendRequestWithoutBody($accessToken, 'GET', $baseUrl, $params);
190
+ } catch (TransferException $e) {
191
+ throw parent::convertException($e);
192
+ }
193
+
194
+ $body = json_decode($response->getBody(), true);
195
+ $optOuts = array();
196
+ foreach ($body['results'] as $opt_out_activity) {
197
+ $optOuts[] = UnsubscribeActivity::create($opt_out_activity);
198
+ }
199
+
200
+ return new ResultSet($optOuts, $body['meta']);
201
+ }
202
+
203
+ /**
204
+ * Get a summary of reporting data for a given campaign
205
+ * @param string $accessToken - Constant Contact OAuth2 access token
206
+ * @param int $campaignId - Campaign id
207
+ * @return TrackingSummary
208
+ * @throws CtctException
209
+ */
210
+ public function getSummary($accessToken, $campaignId) {
211
+ $baseUrl = Config::get('endpoints.base_url') . sprintf(Config::get('endpoints.campaign_tracking_summary'), $campaignId);
212
+
213
+ try {
214
+ $response = parent::sendRequestWithoutBody($accessToken, 'GET', $baseUrl);
215
+ } catch (TransferException $e) {
216
+ throw parent::convertException($e);
217
+ }
218
+
219
+ return TrackingSummary::create(json_decode($response->getBody(), true));
220
+ }
221
+ }
app/api/Ctct/Services/ContactService.php ADDED
@@ -0,0 +1,157 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Ctct\Services;
3
+
4
+ use Ctct\Components\Contacts\Contact;
5
+ use Ctct\Components\ResultSet;
6
+ use Ctct\Exceptions\CtctException;
7
+ use Ctct\Util\Config;
8
+ use GuzzleHttp\Exception\TransferException;
9
+
10
+ /**
11
+ * Performs all actions pertaining to Constant Contact Contacts
12
+ *
13
+ * @package Services
14
+ * @author ContactContact
15
+ */
16
+ class ContactService extends BaseService {
17
+ /**
18
+ * Get a ResultSet of contacts
19
+ * @param string $accessToken - Constant Contact OAuth2 access token
20
+ * @param array $params - associative array of query parameters and values to append to the request.
21
+ * Allowed parameters include:
22
+ * limit - Specifies the number of results displayed per page of output, from 1 - 500, default = 50.
23
+ * modified_since - ISO-8601 formatted timestamp.
24
+ * next - the next link returned from a previous paginated call. May only be used by itself.
25
+ * email - full email address string to restrict results by
26
+ * status - a contact status to filter results by. Must be one of ACTIVE, OPTOUT, REMOVED, UNCONFIRMED.
27
+ * @return ResultSet
28
+ * @throws CtctException
29
+ */
30
+ public function getContacts($accessToken, Array $params = array()) {
31
+ $baseUrl = Config::get('endpoints.base_url') . Config::get('endpoints.contacts');
32
+
33
+ try {
34
+ $response = parent::sendRequestWithoutBody($accessToken, 'GET', $baseUrl, $params);
35
+ } catch (TransferException $e) {
36
+ throw parent::convertException($e);
37
+ }
38
+
39
+ $body = json_decode($response->getBody(), true);
40
+ $contacts = array();
41
+ foreach ($body['results'] as $contact) {
42
+ $contacts[] = Contact::create($contact);
43
+ }
44
+ return new ResultSet($contacts, $body['meta']);
45
+ }
46
+
47
+ /**
48
+ * Get all contacts from an individual list
49
+ * @param string $accessToken - Constant Contact OAuth2 access token
50
+ * @param string $listId - {@link ContactList} id to retrieve contacts for
51
+ * @param array $params - associative array of query parameters and values to append to the request.
52
+ * Allowed parameters include:
53
+ * limit - Specifies the number of results displayed per page of output, from 1 - 500, default = 50.
54
+ * modified_since - ISO-8601 formatted timestamp.
55
+ * next - the next link returned from a previous paginated call. May only be used by itself.
56
+ * email - full email address string to restrict results by
57
+ * status - a contact status to filter results by. Must be one of ACTIVE, OPTOUT, REMOVED, UNCONFIRMED.
58
+ * @return ResultSet
59
+ * @throws CtctException
60
+ */
61
+ public function getContactsFromList($accessToken, $listId, Array $params = array()) {
62
+ $baseUrl = Config::get('endpoints.base_url') . sprintf(Config::get('endpoints.list_contacts'), $listId);
63
+
64
+ try {
65
+ $response = parent::sendRequestWithoutBody($accessToken, 'GET', $baseUrl, $params);
66
+ } catch (TransferException $e) {
67
+ throw parent::convertException($e);
68
+ }
69
+
70
+ $body = json_decode($response->getBody(), true);
71
+ $contacts = array();
72
+ foreach ($body['results'] as $contact) {
73
+ $contacts[] = Contact::create($contact);
74
+ }
75
+ return new ResultSet($contacts, $body['meta']);
76
+ }
77
+
78
+ /**
79
+ * Get contact details for a specific contact
80
+ * @param string $accessToken - Constant Contact OAuth2 access token
81
+ * @param int $contactId - Unique contact id
82
+ * @return Contact
83
+ * @throws CtctException
84
+ */
85
+ public function getContact($accessToken, $contactId) {
86
+ $baseUrl = Config::get('endpoints.base_url') . sprintf(Config::get('endpoints.contact'), $contactId);
87
+
88
+ try {
89
+ $response = parent::sendRequestWithoutBody($accessToken, 'GET', $baseUrl);
90
+ } catch (TransferException $e) {
91
+ throw parent::convertException($e);
92
+ }
93
+
94
+ return Contact::create(json_decode($response->getBody(), true));
95
+ }
96
+
97
+ /**
98
+ * Opt out a contact
99
+ * @param string $accessToken - Constant Contact OAuth2 access token
100
+ * @param int $contactId - Unique contact id
101
+ * @return boolean
102
+ * @throws CtctException
103
+ */
104
+ public function unsubscribeContact($accessToken, $contactId) {
105
+ $baseUrl = Config::get('endpoints.base_url') . sprintf(Config::get('endpoints.contact'), $contactId);
106
+
107
+ try {
108
+ $response = parent::sendRequestWithoutBody($accessToken, 'DELETE', $baseUrl);
109
+ } catch (TransferException $e) {
110
+ throw parent::convertException($e);
111
+ }
112
+
113
+ return ($response->getStatusCode() == 204) ? true : false;
114
+ }
115
+
116
+ /**
117
+ * Add a new contact to the Constant Contact account
118
+ * @param string $accessToken - Constant Contact OAuth2 access token
119
+ * @param Contact $contact - Contact to add
120
+ * @param boolean $actionByContact - true if the creation is being made by the owner of the email address
121
+ * @return Contact
122
+ * @throws CtctException
123
+ */
124
+ public function addContact($accessToken, Contact $contact, $actionByContact) {
125
+ $baseUrl = Config::get('endpoints.base_url') . Config::get('endpoints.contacts');
126
+ $params["action_by"] = ($actionByContact ? "ACTION_BY_VISITOR" : "ACTION_BY_OWNER");
127
+
128
+ try {
129
+ $response = parent::sendRequestWithBody($accessToken, 'POST', $baseUrl, $contact, $params);
130
+ } catch (TransferException $e) {
131
+ throw parent::convertException($e);
132
+ }
133
+
134
+ return Contact::create(json_decode($response->getBody(), true));
135
+ }
136
+
137
+ /**
138
+ * Update contact details for a specific contact
139
+ * @param string $accessToken - Constant Contact OAuth2 access token
140
+ * @param Contact $contact - Contact to be updated
141
+ * @param boolean $actionByContact - true if the update is being made by the owner of the email address
142
+ * @return Contact
143
+ * @throws CtctException
144
+ */
145
+ public function updateContact($accessToken, Contact $contact, $actionByContact) {
146
+ $baseUrl = Config::get('endpoints.base_url') . sprintf(Config::get('endpoints.contact'), $contact->id);
147
+ $params["action_by"] = ($actionByContact ? "ACTION_BY_VISITOR" : "ACTION_BY_OWNER");
148
+
149
+ try {
150
+ $response = parent::sendRequestWithBody($accessToken, 'PUT', $baseUrl, $contact, $params);
151
+ } catch (TransferException $e) {
152
+ throw parent::convertException($e);
153
+ }
154
+
155
+ return Contact::create(json_decode($response->getBody(), true));
156
+ }
157
+ }
app/api/Ctct/Services/ContactTrackingService.php ADDED
@@ -0,0 +1,221 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Ctct\Services;
3
+
4
+ use Ctct\Components\ResultSet;
5
+ use Ctct\Components\Tracking\BounceActivity;
6
+ use Ctct\Components\Tracking\ClickActivity;
7
+ use Ctct\Components\Tracking\ForwardActivity;
8
+ use Ctct\Components\Tracking\OpenActivity;
9
+ use Ctct\Components\Tracking\SendActivity;
10
+ use Ctct\Components\Tracking\TrackingSummary;
11
+ use Ctct\Components\Tracking\UnsubscribeActivity;
12
+ use Ctct\Exceptions\CtctException;
13
+ use Ctct\Util\Config;
14
+ use GuzzleHttp\Exception\TransferException;
15
+
16
+ /**
17
+ * Performs all actions pertaining to Contact Tracking
18
+ *
19
+ * @package Services
20
+ * @author Constant Contact
21
+ */
22
+ class ContactTrackingService extends BaseService {
23
+ /**
24
+ * Get bounces for a given contact
25
+ * @param string $accessToken - Constant Contact OAuth2 access token
26
+ * @param string $contactId - Contact id
27
+ * @param array $params - associative array of query parameters and values to append to the request.
28
+ * Allowed parameters include:
29
+ * limit - Specifies the number of results displayed per page of output, from 1 - 500, default = 50.
30
+ * created_since - Used to retrieve a list of events since the date and time specified (in ISO-8601 format).
31
+ * next - the next link returned from a previous paginated call. May only be used by itself.
32
+ * @return ResultSet - Containing a results array of {@link BounceActivity}
33
+ * @throws CtctException
34
+ */
35
+ public function getBounces($accessToken, $contactId, Array $params = array()) {
36
+ $baseUrl = Config::get('endpoints.base_url') . sprintf(Config::get('endpoints.contact_tracking_bounces'), $contactId);
37
+
38
+ try {
39
+ $response = parent::sendRequestWithoutBody($accessToken, 'GET', $baseUrl, $params);
40
+ } catch (TransferException $e) {
41
+ throw parent::convertException($e);
42
+ }
43
+
44
+ $body = json_decode($response->getBody(), true);
45
+ $bounces = array();
46
+ foreach ($body['results'] as $bounceActivity) {
47
+ $bounces[] = BounceActivity::create($bounceActivity);
48
+ }
49
+
50
+ return new ResultSet($bounces, $body['meta']);
51
+ }
52
+
53
+ /**
54
+ * Get clicks for a given contact
55
+ * @param string $accessToken - Constant Contact OAuth2 access token
56
+ * @param string $contactId - Contact id
57
+ * @param array $params - associative array of query parameters and values to append to the request.
58
+ * Allowed parameters include:
59
+ * limit - Specifies the number of results displayed per page of output, from 1 - 500, default = 50.
60
+ * created_since - Used to retrieve a list of events since the date and time specified (in ISO-8601 format).
61
+ * next - the next link returned from a previous paginated call. May only be used by itself.
62
+ * @return ResultSet - Containing a results array of {@link ClickActivity}
63
+ * @throws CtctException
64
+ */
65
+ public function getClicks($accessToken, $contactId, Array $params = array()) {
66
+ $baseUrl = Config::get('endpoints.base_url') . sprintf(Config::get('endpoints.contact_tracking_clicks'), $contactId);
67
+
68
+ try {
69
+ $response = parent::sendRequestWithoutBody($accessToken, 'GET', $baseUrl, $params);
70
+ } catch (TransferException $e) {
71
+ throw parent::convertException($e);
72
+ }
73
+
74
+ $body = json_decode($response->getBody(), true);
75
+ $clicks = array();
76
+ foreach ($body['results'] as $click_activity) {
77
+ $clicks[] = ClickActivity::create($click_activity);
78
+ }
79
+
80
+ return new ResultSet($clicks, $body['meta']);
81
+ }
82
+
83
+ /**
84
+ * Get forwards for a given contact
85
+ * @param string $accessToken - Constant Contact OAuth2 access token
86
+ * @param string $contactId - Contact id
87
+ * @param array $params - associative array of query parameters and values to append to the request.
88
+ * Allowed parameters include:
89
+ * limit - Specifies the number of results displayed per page of output, from 1 - 500, default = 50.
90
+ * created_since - Used to retrieve a list of events since the date and time specified (in ISO-8601 format).
91
+ * next - the next link returned from a previous paginated call. May only be used by itself.
92
+ * @return ResultSet - Containing a results array of {@link ForwardActivity}
93
+ * @throws CtctException
94
+ */
95
+ public function getForwards($accessToken, $contactId, Array $params = array()) {
96
+ $baseUrl = Config::get('endpoints.base_url') . sprintf(Config::get('endpoints.contact_tracking_forwards'), $contactId);
97
+
98
+ try {
99
+ $response = parent::sendRequestWithoutBody($accessToken, 'GET', $baseUrl, $params);
100
+ } catch (TransferException $e) {
101
+ throw parent::convertException($e);
102
+ }
103
+
104
+ $body = json_decode($response->getBody(), true);
105
+ $forwards = array();
106
+ foreach ($body['results'] as $forward_activity) {
107
+ $forwards[] = ForwardActivity::create($forward_activity);
108
+ }
109
+
110
+ return new ResultSet($forwards, $body['meta']);
111
+ }
112
+
113
+ /**
114
+ * Get opens for a given contact
115
+ * @param string $accessToken - Constant Contact OAuth2 access token
116
+ * @param string $contactId - Contact id
117
+ * @param array $params - associative array of query parameters and values to append to the request.
118
+ * Allowed parameters include:
119
+ * limit - Specifies the number of results displayed per page of output, from 1 - 500, default = 50.
120
+ * created_since - Used to retrieve a list of events since the date and time specified (in ISO-8601 format).
121
+ * next - the next link returned from a previous paginated call. May only be used by itself.
122
+ * @return ResultSet - Containing a results array of {@link OpenActivity}
123
+ * @throws CtctException
124
+ */
125
+ public function getOpens($accessToken, $contactId, Array $params = array()) {
126
+ $baseUrl = Config::get('endpoints.base_url') . sprintf(Config::get('endpoints.contact_tracking_opens'), $contactId);
127
+
128
+ try {
129
+ $response = parent::sendRequestWithoutBody($accessToken, 'GET', $baseUrl, $params);
130
+ } catch (TransferException $e) {
131
+ throw parent::convertException($e);
132
+ }
133
+
134
+ $body = json_decode($response->getBody(), true);
135
+ $opens = array();
136
+ foreach ($body['results'] as $open_activity) {
137
+ $opens[] = OpenActivity::create($open_activity);
138
+ }
139
+
140
+ return new ResultSet($opens, $body['meta']);
141
+ }
142
+
143
+ /**
144
+ * Get sends for a given contact
145
+ * @param string $accessToken - Constant Contact OAuth2 access token
146
+ * @param string $contactId - Contact id
147
+ * @param array $params - associative array of query parameters and values to append to the request.
148
+ * Allowed parameters include:
149
+ * limit - Specifies the number of results displayed per page of output, from 1 - 500, default = 50.
150
+ * created_since - Used to retrieve a list of events since the date and time specified (in ISO-8601 format).
151
+ * next - the next link returned from a previous paginated call. May only be used by itself.
152
+ * @return ResultSet - Containing a results array of {@link SendActivity}
153
+ * @throws CtctException
154
+ */
155
+ public function getSends($accessToken, $contactId, Array $params = array()) {
156
+ $baseUrl = Config::get('endpoints.base_url') . sprintf(Config::get('endpoints.contact_tracking_sends'), $contactId);
157
+
158
+ try {
159
+ $response = parent::sendRequestWithoutBody($accessToken, 'GET', $baseUrl, $params);
160
+ } catch (TransferException $e) {
161
+ throw parent::convertException($e);
162
+ }
163
+
164
+ $body = json_decode($response->getBody(), true);
165
+ $sends = array();
166
+ foreach ($body['results'] as $send_activity) {
167
+ $sends[] = SendActivity::create($send_activity);
168
+ }
169
+
170
+ return new ResultSet($sends, $body['meta']);
171
+ }
172
+
173
+ /**
174
+ * Get unsubscribes for a given contact
175
+ * @param string $accessToken - Constant Contact OAuth2 access token
176
+ * @param string $contactId - Contact id
177
+ * @param array $params - associative array of query parameters and values to append to the request.
178
+ * Allowed parameters include:
179
+ * limit - Specifies the number of results displayed per page of output, from 1 - 500, default = 50.
180
+ * created_since - Used to retrieve a list of events since the date and time specified (in ISO-8601 format).
181
+ * next - the next link returned from a previous paginated call. May only be used by itself.
182
+ * @return ResultSet - Containing a results array of {@link UnsubscribeActivity}
183
+ * @throws CtctException
184
+ */
185
+ public function getUnsubscribes($accessToken, $contactId, Array $params = array()) {
186
+ $baseUrl = Config::get('endpoints.base_url') . sprintf(Config::get('endpoints.contact_tracking_unsubscribes'), $contactId);
187
+
188
+ try {
189
+ $response = parent::sendRequestWithoutBody($accessToken, 'GET', $baseUrl, $params);
190
+ } catch (TransferException $e) {
191
+ throw parent::convertException($e);
192
+ }
193
+
194
+ $body = json_decode($response->getBody(), true);
195
+ $opt_outs = array();
196
+ foreach ($body['results'] as $opt_out_activity) {
197
+ $opt_outs[] = UnsubscribeActivity::create($opt_out_activity);
198
+ }
199
+
200
+ return new ResultSet($opt_outs, $body['meta']);
201
+ }
202
+
203
+ /**
204
+ * Get a summary of reporting data for a given contact
205
+ * @param string $accessToken - Constant Contact OAuth2 access token
206
+ * @param string $contactId - Contact id
207
+ * @return TrackingSummary
208
+ * @throws CtctException
209
+ */
210
+ public function getSummary($accessToken, $contactId) {
211
+ $baseUrl = Config::get('endpoints.base_url') . sprintf(Config::get('endpoints.contact_tracking_summary'), $contactId);
212
+
213
+ try {
214
+ $response = parent::sendRequestWithoutBody($accessToken, 'GET', $baseUrl);
215
+ } catch (TransferException $e) {
216
+ throw parent::convertException($e);
217
+ }
218
+
219
+ return TrackingSummary::create(json_decode($response->getBody(), true));
220
+ }
221
+ }
app/api/Ctct/Services/EmailMarketingService.php ADDED
@@ -0,0 +1,145 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Ctct\Services;
3
+
4
+ use Ctct\Components\EmailMarketing\Campaign;
5
+ use Ctct\Components\EmailMarketing\CampaignPreview;
6
+ use Ctct\Components\ResultSet;
7
+ use Ctct\Exceptions\CtctException;
8
+ use Ctct\Util\Config;
9
+ use GuzzleHttp\Exception\TransferException;
10
+
11
+ /**
12
+ * Performs all actions pertaining to Constant Contact Campaigns
13
+ *
14
+ * @package Services
15
+ * @author Constant Contact
16
+ */
17
+ class EmailMarketingService extends BaseService {
18
+ /**
19
+ * Create a new campaign
20
+ * @param string $accessToken - Constant Contact OAuth2 access token
21
+ * @param Campaign $campaign - Campaign to be created
22
+ * @return Campaign
23
+ * @throws CtctException
24
+ */
25
+ public function addCampaign($accessToken, Campaign $campaign) {
26
+ $baseUrl = Config::get('endpoints.base_url') . Config::get('endpoints.campaigns');
27
+ if ($campaign->message_footer == null) {
28
+ // API doesn't work well with a null message footer, so omit it entirely.
29
+ unset($campaign->message_footer);
30
+ }
31
+
32
+ try {
33
+ $response = parent::sendRequestWithBody($accessToken, 'POST', $baseUrl, $campaign);
34
+ } catch (TransferException $e) {
35
+ throw parent::convertException($e);
36
+ }
37
+
38
+ return Campaign::create(json_decode($response->getBody(), true));
39
+ }
40
+
41
+ /**
42
+ * Get a set of campaigns
43
+ * @param string $accessToken - Constant Contact OAuth2 access token
44
+ * @param array $params - associative array of query parameters and values to append to the request.
45
+ * Allowed parameters include:
46
+ * limit - Specifies the number of results displayed per page of output, from 1 - 500, default = 50.
47
+ * modified_since - ISO-8601 formatted timestamp.
48
+ * next - the next link returned from a previous paginated call. May only be used by itself.
49
+ * @return ResultSet
50
+ * @throws CtctException
51
+ */
52
+ public function getCampaigns($accessToken, Array $params = array()) {
53
+ $baseUrl = Config::get('endpoints.base_url') . Config::get('endpoints.campaigns');
54
+
55
+ try {
56
+ $response = parent::sendRequestWithoutBody($accessToken, 'GET', $baseUrl, $params);
57
+ } catch (TransferException $e) {
58
+ throw parent::convertException($e);
59
+ }
60
+
61
+ $body = json_decode($response->getBody(), true);
62
+ $campaigns = array();
63
+ foreach ($body['results'] as $contact) {
64
+ $campaigns[] = Campaign::createSummary($contact);
65
+ }
66
+
67
+ return new ResultSet($campaigns, $body['meta']);
68
+ }
69
+
70
+ /**
71
+ * Get campaign details for a specific campaign
72
+ * @param string $accessToken - Constant Contact OAuth2 access token
73
+ * @param int $campaignId - Valid campaign id
74
+ * @return Campaign
75
+ * @throws CtctException
76
+ */
77
+ public function getCampaign($accessToken, $campaignId) {
78
+ $baseUrl = Config::get('endpoints.base_url') . sprintf(Config::get('endpoints.campaign'), $campaignId);
79
+
80
+ try {
81
+ $response = parent::sendRequestWithoutBody($accessToken, 'GET', $baseUrl);
82
+ } catch (TransferException $e) {
83
+ throw parent::convertException($e);
84
+ }
85
+
86
+ return Campaign::create(json_decode($response->getBody(), true));
87
+ }
88
+
89
+ /**
90
+ * Delete an email campaign
91
+ * @param string $accessToken - Constant Contact OAuth2 access token
92
+ * @param int $campaignId - Valid campaign id
93
+ * @return boolean
94
+ * @throws CtctException
95
+ */
96
+ public function deleteCampaign($accessToken, $campaignId) {
97
+ $baseUrl = Config::get('endpoints.base_url') . sprintf(Config::get('endpoints.campaign'), $campaignId);
98
+
99
+ try {
100
+ $response = parent::sendRequestWithoutBody($accessToken, 'DELETE', $baseUrl);
101
+ } catch (TransferException $e) {
102
+ throw parent::convertException($e);
103
+ }
104
+
105
+ return ($response->getStatusCode() == 204) ? true : false;
106
+ }
107
+
108
+ /**
109
+ * Update a specific email campaign
110
+ * @param string $accessToken - Constant Contact OAuth2 access token
111
+ * @param Campaign $campaign - Campaign to be updated
112
+ * @return Campaign
113
+ * @throws CtctException
114
+ */
115
+ public function updateCampaign($accessToken, Campaign $campaign) {
116
+ $baseUrl = Config::get('endpoints.base_url') . sprintf(Config::get('endpoints.campaign'), $campaign->id);
117
+
118
+ try {
119
+ $response = parent::sendRequestWithBody($accessToken, 'PUT', $baseUrl, $campaign);
120
+ } catch (TransferException $e) {
121
+ throw parent::convertException($e);
122
+ }
123
+
124
+ return Campaign::create(json_decode($response->getBody(), true));
125
+ }
126
+
127
+ /**
128
+ * Get a preview of an email campaign
129
+ * @param string $accessToken - Constant Contact OAuth2 access token
130
+ * @param int $campaignId - Valid campaign id
131
+ * @return CampaignPreview
132
+ * @throws CtctException
133
+ */
134
+ public function getPreview($accessToken, $campaignId) {
135
+ $baseUrl = Config::get('endpoints.base_url') . sprintf(Config::get('endpoints.campaign_preview'), $campaignId);
136
+
137
+ try {
138
+ $response = parent::sendRequestWithoutBody($accessToken, 'GET', $baseUrl);
139
+ } catch (TransferException $e) {
140
+ throw parent::convertException($e);
141
+ }
142
+
143
+ return CampaignPreview::create(json_decode($response->getBody(), true));
144
+ }
145
+ }
app/api/Ctct/Services/EventSpotService.php ADDED
@@ -0,0 +1,329 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Ctct\Services;
3
+
4
+ use Ctct\Components\EventSpot\Registrant\Promocode;
5
+ use Ctct\Components\EventSpot\Registrant\Registrant;
6
+ use Ctct\Services;
7
+ use Ctct\Components\ResultSet;
8
+ use Ctct\Components\EventSpot\EventSpot;
9
+ use Ctct\Components\EventSpot\EventFee;
10
+ use Ctct\Components\EventSpot\EventSpotList;
11
+ use Ctct\Exceptions\CtctException;
12
+ use Ctct\Util\Config;
13
+ use Ctct\Components\Contacts\ContactList;
14
+ use GuzzleHttp\Exception\ClientException;
15
+ use GuzzleHttp\Exception\TransferException;
16
+ use GuzzleHttp\Psr7;
17
+
18
+ /**
19
+ * Performs all actions pertaining to Constant Contact EventSpot Events
20
+ *
21
+ * @package Services
22
+ * @author Constant Contact
23
+ */
24
+ class EventSpotService extends BaseService
25
+ {
26
+
27
+ /**
28
+ * Get lists within an account
29
+ * @param string $accessToken Constant Contact OAuth2 access token
30
+ * @param array $params - associative array of query parameters and values to append to the request.
31
+ * Allowed parameters include:
32
+ * limit - Default: 50, up to 500
33
+ * @return ResultSet
34
+ * @throws CtctException
35
+ */
36
+ public function getEvents($accessToken, Array $params = array())
37
+ {
38
+ $baseUrl = Config::get('endpoints.base_url') . Config::get('endpoints.events');
39
+
40
+ try {
41
+ $response = parent::sendRequestWithoutBody($accessToken, 'GET', $baseUrl, $params);
42
+ } catch (ClientException $e) {
43
+ throw parent::convertException($e);
44
+ }
45
+
46
+ $body = json_decode($response->getBody(), true);
47
+
48
+ $events = array();
49
+ if( ! empty( $body['results'] ) ) {
50
+ foreach ( $body['results'] as $event ) {
51
+ $events[] = EventSpot::create( $event );
52
+ }
53
+ }
54
+
55
+ return new ResultSet($events, $body['meta']);
56
+ }
57
+
58
+ /**
59
+ * Create a new Event
60
+ * @param string $accessToken Constant Contact OAuth2 access token
61
+ * @param EventSpot $event
62
+ * @return EventSpot
63
+ * @throws CtctException
64
+ */
65
+ public function addEvent($accessToken, EventSpot $event)
66
+ {
67
+ $baseUrl = Config::get('endpoints.base_url') . Config::get('endpoints.events');
68
+
69
+ try {
70
+ $response = parent::sendRequestWithBody($accessToken, 'POST', $baseUrl, $event);
71
+ } catch (ClientException $e) {
72
+ throw parent::convertException($e);
73
+ }
74
+
75
+ return EventSpot::create(json_decode($response->getBody(), true));
76
+ }
77
+
78
+ /**
79
+ * Update an EventSpot Event
80
+ * @param string $accessToken Constant Contact OAuth2 access token
81
+ * @param EventSpot $event - EventSpot to be updated
82
+ * @return EventSpot
83
+ * @throws CtctException
84
+ */
85
+ public function updateEvent($accessToken, EventSpot $event)
86
+ {
87
+ $baseUrl = Config::get('endpoints.base_url') . sprintf(Config::get('endpoints.event'), $event->id);
88
+
89
+ try {
90
+ $response = parent::sendRequestWithBody($accessToken, 'PUT', $baseUrl, $event);
91
+ } catch (TransferException $e) {
92
+ throw parent::convertException($e);
93
+ }
94
+
95
+ return EventSpot::create(json_decode($response->getBody(), true));
96
+ }
97
+
98
+ /**
99
+ * Delete an Event
100
+ * @param string $accessToken Constant Contact OAuth2 access token
101
+ * @param string|int $eventId - event id
102
+ * @return boolean
103
+ * @throws CtctException
104
+ */
105
+ public function deleteEvent($accessToken, $eventId)
106
+ {
107
+ $baseUrl = Config::get('endpoints.base_url') . sprintf(Config::get('endpoints.event'), $eventId);
108
+
109
+ try {
110
+ $response = parent::sendRequestWithoutBody($accessToken, 'DELETE', $baseUrl);
111
+ } catch (TransferException $e) {
112
+ throw parent::convertException($e);
113
+ }
114
+
115
+ return ($response->getStatusCode() == 204) ? true : false;
116
+ }
117
+
118
+ /**
119
+ * Get an individual Event
120
+ * @param $accessToken - Constant Contact OAuth2 access token
121
+ * @param $eventId - event id
122
+ * @return EventSpot
123
+ * @throws CtctException
124
+ */
125
+ public function getEvent($accessToken, $eventId)
126
+ {
127
+ $baseUrl = Config::get('endpoints.base_url') . sprintf(Config::get('endpoints.event'), $eventId);
128
+
129
+ try {
130
+ $response = parent::sendRequestWithoutBody($accessToken, 'GET', $baseUrl);
131
+ } catch (TransferException $e) {
132
+ throw parent::convertException($e);
133
+ }
134
+
135
+ $event_array = json_decode($response->getBody(), true);
136
+ $event_array['id'] = $eventId;
137
+
138
+ return EventSpot::create($event_array);
139
+ }
140
+
141
+ /**
142
+ * Get lists within an account
143
+ * @param string $accessToken Constant Contact OAuth2 access token
144
+ * @param string $eventId Unique ID of the event for which to retrieve the promocode
145
+ * @param array $params - associative array of query parameters and values to append to the request.
146
+ * Allowed parameters include:
147
+ * limit - Default: 50, up to 500
148
+ * @return EventSpot[]
149
+ * @throws CtctException
150
+ */
151
+ public function getRegistrants($accessToken, $eventId, Array $params = array())
152
+ {
153
+ $baseUrl = Config::get('endpoints.base_url') . sprintf( Config::get('endpoints.event_registrants'), $eventId );
154
+
155
+ try {
156
+ $response = parent::sendRequestWithoutBody($accessToken, 'GET', $baseUrl, $params);
157
+ } catch (TransferException $e) {
158
+ throw parent::convertException($e);
159
+ }
160
+
161
+ $body = json_decode($response->getBody(), true);
162
+ $registrants = array();
163
+ foreach ($body['results'] as $registrant) {
164
+ $registrants[] = Registrant::create($registrant);
165
+ }
166
+
167
+ return new ResultSet($registrants, $body['meta']);
168
+ }
169
+
170
+ /**
171
+ * Create a new Event
172
+ * @param string $accessToken Constant Contact OAuth2 access token
173
+ * @param string $eventId Unique ID of the event for which to retrieve the promocode
174
+ * @param string $registrantId ID of the registrant
175
+ * @return Registrant
176
+ * @throws CtctException
177
+ */
178
+ public function getRegistrant($accessToken, $eventId, $registrantId )
179
+ {
180
+ $baseUrl = Config::get('endpoints.base_url') . sprintf( Config::get('endpoints.event_registrant'), $eventId, $registrantId );
181
+
182
+ try {
183
+ $response = parent::sendRequestWithoutBody($accessToken, 'GET', $baseUrl);
184
+ } catch (TransferException $e) {
185
+ throw parent::convertException($e);
186
+ }
187
+
188
+ return Registrant::create(json_decode($response->getBody(), true));
189
+ }
190
+
191
+ /**
192
+ * Create a new Event
193
+ * @param string $accessToken Constant Contact OAuth2 access token
194
+ * @param string $eventId Unique ID of the event for which to retrieve the promocode
195
+ * @param EventFee $eventFee EventFee object to create
196
+ * @return EventFee Created EventFee object
197
+ * @throws CtctException
198
+ */
199
+ public function addFee($accessToken, $eventId, $eventFee )
200
+ {
201
+ $baseUrl = Config::get('endpoints.base_url') . sprintf( Config::get('endpoints.event_fees'), $eventId );
202
+
203
+ try {
204
+ $response = parent::sendRequestWithBody($accessToken, 'POST', $baseUrl, $eventFee);
205
+ } catch (TransferException $e) {
206
+ throw parent::convertException($e);
207
+ }
208
+
209
+ return EventFee::create(json_decode($response->getBody(), true));
210
+ }
211
+
212
+ /**
213
+ * Get fees for an event
214
+ * @param string $accessToken Constant Contact OAuth2 access token
215
+ * @param string $eventId Unique ID of the event for which to retrieve the promocode
216
+ * @return EventFee[]
217
+ * @throws CtctException
218
+ */
219
+ public function getFees($accessToken, $eventId )
220
+ {
221
+ $baseUrl = Config::get('endpoints.base_url') . sprintf( Config::get('endpoints.event_fees'), $eventId );
222
+
223
+ try {
224
+ $response = parent::sendRequestWithoutBody($accessToken, 'GET', $baseUrl);
225
+ } catch (TransferException $e) {
226
+ throw parent::convertException($e);
227
+ }
228
+
229
+ $body = json_decode($response->getBody(), true);
230
+ $fees = array();
231
+ foreach ($body['results'] as $fee) {
232
+ $fees[] = EventFee::create($fee);
233
+ }
234
+
235
+ return $fees;
236
+ }
237
+
238
+ /**
239
+ * Get an individual Event fee
240
+ * @param string $accessToken Constant Contact OAuth2 access token
241
+ * @param string $eventId Unique ID of the event for which to retrieve the promocode
242
+ * @param string $feeId Unique ID of the fee to retrieve
243
+ * @return EventSpot
244
+ * @throws CtctException
245
+ */
246
+ public function getFee($accessToken, $eventId, $feeId)
247
+ {
248
+ $baseUrl = Config::get('endpoints.base_url') . sprintf(Config::get('endpoints.event_fee'), $eventId, $feeId);
249
+
250
+
251
+ try {
252
+ $response = parent::sendRequestWithoutBody($accessToken, 'GET', $baseUrl);
253
+ } catch (TransferException $e) {
254
+ throw parent::convertException($e);
255
+ }
256
+
257
+ return EventFee::create(json_decode($response->getBody(), true));
258
+ }
259
+
260
+ /**
261
+ * Create a new Promocode
262
+ * @param string $accessToken Constant Contact OAuth2 access token
263
+ * @param string $eventId Unique ID of the event for which to retrieve the promocode
264
+ * @param Promocode $promoCode Promocode object to add
265
+ * @return Promocode Created promocode object
266
+ * @throws CtctException
267
+ */
268
+ public function addPromocode($accessToken, $eventId, $promoCode )
269
+ {
270
+ $baseUrl = Config::get('endpoints.base_url') . sprintf( Config::get('endpoints.event_promocodes'), $eventId );
271
+
272
+ try {
273
+ $response = parent::sendRequestWithBody($accessToken, 'POST', $baseUrl, $promoCode);
274
+ } catch (TransferException $e) {
275
+ throw parent::convertException($e);
276
+ }
277
+
278
+ return Promocode::create(json_decode($response->getBody(), true));
279
+ }
280
+
281
+ /**
282
+ * Get promocodes for an event
283
+ * @param string $accessToken Constant Contact OAuth2 access token
284
+ * @param string $eventId Unique ID of the event for which to retrieve the promocode
285
+ * @return Promocode[]
286
+ * @throws CtctException
287
+ */
288
+ public function getPromocodes($accessToken, $eventId )
289
+ {
290
+ $baseUrl = Config::get('endpoints.base_url') . sprintf( Config::get('endpoints.event_promocodes'), $eventId );
291
+
292
+ try {
293
+ $response = parent::sendRequestWithoutBody($accessToken, 'GET', $baseUrl);
294
+ } catch (TransferException $e) {
295
+ throw parent::convertException($e);
296
+ }
297
+
298
+ $body = json_decode($response->getBody(), true);
299
+ $promocodes = array();
300
+ foreach ($body['results'] as $promocode) {
301
+ $promocodes[] = Promocode::create($promocode);
302
+ }
303
+
304
+ return $promocodes;
305
+ }
306
+
307
+ /**
308
+ * Get an individual Promocode fee
309
+ * @param string $accessToken Constant Contact OAuth2 access token
310
+ * @param string $eventId Unique ID of the event for which to retrieve the promocode
311
+ * @param string $promocodeId Unique ID of the promocode to retrieve
312
+ * @return Promocode
313
+ * @throws CtctException
314
+ */
315
+ public function getPromocode($accessToken, $eventId, $promocodeId)
316
+ {
317
+ $baseUrl = Config::get('endpoints.base_url') . sprintf(Config::get('endpoints.event_promocode'), $eventId, $promocodeId);
318
+
319
+
320
+ try {
321
+ $response = parent::sendRequestWithoutBody($accessToken, 'GET', $baseUrl);
322
+ } catch (TransferException $e) {
323
+ throw parent::convertException($e);
324
+ }
325
+
326
+ return Promocode::create(json_decode($response->getBody(), true));
327
+ }
328
+
329
+ }
app/api/Ctct/Services/LibraryService.php ADDED
@@ -0,0 +1,283 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Ctct\Services;
3
+
4
+ use Ctct\Components\Library\File;
5
+ use Ctct\Components\Library\FileUploadStatus;
6
+ use Ctct\Components\Library\Folder;
7
+ use Ctct\Components\ResultSet;
8
+ use Ctct\Exceptions\CtctException;
9
+ use Ctct\Exceptions\IllegalArgumentException;
10
+ use Ctct\Util\Config;
11
+ use GuzzleHttp\Exception\TransferException;
12
+ use GuzzleHttp\Psr7\Request;
13
+
14
+ class LibraryService extends BaseService {
15
+ /**
16
+ * Get files from the Library
17
+ * @param string $accessToken - Constant Contact OAuth2 Access Token
18
+ * @param array $params - associative array of query parameters and values to append to the request.
19
+ * Allowed parameters include:
20
+ * limit - Specifies the number of results displayed per page of output, from 1 - 1000, default = 50.
21
+ * sort_by - Specifies how the list of files is sorted; valid sort options are:
22
+ * CREATED_DATE, CREATED_DATE_DESC, MODIFIED_DATE, MODIFIED_DATE_DESC, NAME, NAME_DESC, SIZE, SIZE_DESC DIMENSION, DIMENSION_DESC
23
+ * source - Specifies to retrieve files from a particular source:
24
+ * ALL, MyComputer, Facebook, Instagram, Shutterstock, Mobile
25
+ * next - the next link returned from a previous paginated call. May only be used by itself.
26
+ * @return ResultSet
27
+ * @throws CtctException
28
+ */
29
+ public function getLibraryFiles($accessToken, Array $params = array()) {
30
+ $baseUrl = Config::get('endpoints.base_url') . Config::get('endpoints.library_files');
31
+
32
+ try {
33
+ $response = parent::sendRequestWithoutBody($accessToken, 'GET', $baseUrl, $params);
34
+ } catch (TransferException $e) {
35
+ throw parent::convertException($e);
36
+ }
37
+
38
+ $body = json_decode($response->getBody(), true);
39
+ $libraryFiles = array();
40
+ foreach ($body['results'] as $file) {
41
+ $libraryFiles[] = File::create($file);
42
+ }
43
+
44
+ return new ResultSet($libraryFiles, $body['meta']);
45
+ }
46
+
47
+ /**
48
+ * Get files from the Library in a specific Folder
49
+ * @param string $accessToken - Constant Contact OAuth2 Access Token
50
+ * @param string $folderId - Specified Folder Id
51
+ * @param array $params - associative array of query parameters and values to append to the request.
52
+ * Allowed parameters include:
53
+ * limit - Specifies the number of results displayed per page of output, from 1 - 1000, default = 50.
54
+ * sort_by - Specifies how the list of files is sorted; valid sort options are:
55
+ * CREATED_DATE, CREATED_DATE_DESC, MODIFIED_DATE, MODIFIED_DATE_DESC, NAME, NAME_DESC, SIZE, SIZE_DESC DIMENSION, DIMENSION_DESC
56
+ * source - Specifies to retrieve files from a particular source:
57
+ * ALL, MyComputer, Facebook, Instagram, Shutterstock, Mobile
58
+ * next - the next link returned from a previous paginated call. May only be used by itself.
59
+ * @return ResultSet
60
+ * @throws CtctException
61
+ */
62
+ public function getLibraryFilesByFolder($accessToken, $folderId, Array $params = array()) {
63
+ $baseUrl = Config::get('endpoints.base_url') . sprintf(Config::get('endpoints.library_files_by_folder'), $folderId);
64
+
65
+ try {
66
+ $response = parent::sendRequestWithoutBody($accessToken, 'GET', $baseUrl, $params);
67
+ } catch (TransferException $e) {
68
+ throw parent::convertException($e);
69
+ }
70
+
71
+ $body = json_decode($response->getBody(), true);
72
+ $libraryFiles = array();
73
+ foreach ($body['results'] as $file) {
74
+ $libraryFiles[] = File::create($file);
75
+ }
76
+
77
+ return new ResultSet($libraryFiles, $body['meta']);
78
+ }
79
+
80
+ /**
81
+ * Get File by Id
82
+ * @param string $accessToken - Constant Contact OAuth2 Access Token
83
+ * @param string $fileId - Specified File Id
84
+ * @return File
85
+ * @throws CtctException
86
+ */
87
+ public function getLibraryFile($accessToken, $fileId) {
88
+ $baseUrl = Config::get('endpoints.base_url') . sprintf(Config::get('endpoints.library_file'), $fileId);
89
+
90
+ try {
91
+ $response = parent::sendRequestWithoutBody($accessToken, 'GET', $baseUrl);
92
+ } catch (TransferException $e) {
93
+ throw parent::convertException($e);
94
+ }
95
+
96
+ return File::create(json_decode($response->getBody(), true));
97
+ }
98
+
99
+ /**
100
+ * Delete a File
101
+ * @param string $accessToken - Constant Contact OAuth2 Access Token
102
+ * @param string $fileId - Specified File Id
103
+ * @return boolean
104
+ * @throws CtctException
105
+ */
106
+ public function deleteLibraryFile($accessToken, $fileId) {
107
+ $baseUrl = Config::get('endpoints.base_url') . sprintf(Config::get('endpoints.library_file'), $fileId);
108
+
109
+ try {
110
+ $response = parent::sendRequestWithoutBody($accessToken, 'DELETE', $baseUrl);
111
+ } catch (TransferException $e) {
112
+ throw parent::convertException($e);
113
+ }
114
+
115
+ return ($response->getStatusCode() == 204) ? true : false;
116
+ }
117
+
118
+ /**
119
+ * Get folders from the Library
120
+ * @param string $accessToken - Constant Contact OAuth2 Access Token
121
+ * @param array $params - associative array of query parameters and values to append to the request.
122
+ * Allowed parameters include:
123
+ * limit - Specifies the number of results displayed per page of output, from 1 - 1000, default = 50.
124
+ * sort_by - Specifies how the list of files is sorted; valid sort options are:
125
+ * CREATED_DATE, CREATED_DATE_DESC, MODIFIED_DATE, MODIFIED_DATE_DESC, NAME, NAME_DESC
126
+ * @return ResultSet
127
+ * @throws CtctException
128
+ */
129
+ public function getLibraryFolders($accessToken, Array $params = array()) {
130
+ $baseUrl = Config::get('endpoints.base_url') . Config::get('endpoints.library_folders');
131
+
132
+ try {
133
+ $response = parent::sendRequestWithoutBody($accessToken, 'GET', $baseUrl, $params);
134
+ } catch (TransferException $e) {
135
+ throw parent::convertException($e);
136
+ }
137
+
138
+ $body = json_decode($response->getBody(), true);
139
+ $libraryFolders = array();
140
+ foreach ($body['results'] as $folder) {
141
+ $libraryFolders[] = Folder::create($folder);
142
+ }
143
+
144
+ return new ResultSet($libraryFolders, $body['meta']);
145
+ }
146
+
147
+ /**
148
+ * Get a specific Folder
149
+ * @param string $accessToken - Constant Contact OAuth2 Access Token
150
+ * @param string $folderId - ID of the Folder
151
+ * @return Folder
152
+ * @throws CtctException
153
+ */
154
+ public function getLibraryFolder($accessToken, $folderId) {
155
+ $baseUrl = Config::get('endpoints.base_url') . sprintf(Config::get('endpoints.library_folder'), $folderId);
156
+
157
+ try {
158
+ $response = parent::sendRequestWithoutBody($accessToken, 'GET', $baseUrl);
159
+ } catch (TransferException $e) {
160
+ throw parent::convertException($e);
161
+ }
162
+
163
+ $body = json_decode($response->getBody(), true);
164
+ return Folder::create($body);
165
+ }
166
+
167
+ /**
168
+ * Delete a Library Folder
169
+ * @param string $accessToken - Constant Contact OAuth2 Access Token
170
+ * @param string $folderId - ID of the Folder
171
+ * @return boolean
172
+ * @throws CtctException
173
+ */
174
+ public function deleteLibraryFolder($accessToken, $folderId) {
175
+ $baseUrl = Config::get('endpoints.base_url') . sprintf(Config::get('endpoints.library_folder'), $folderId);
176
+
177
+ try {
178
+ $response = parent::sendRequestWithoutBody($accessToken, 'DELETE', $baseUrl);
179
+ } catch (TransferException $e) {
180
+ throw parent::convertException($e);
181
+ }
182
+
183
+ return ($response->getStatusCode() == 204) ? true : false;
184
+ }
185
+
186
+ /**
187
+ * Upload a file to the Library. Must be one of PNG, JPG, JPEG, GIF, or PDF.
188
+ * The server scans files for viruses, so this returns an ID for a FileUploadStatus.
189
+ * @param string $accessToken - Constant Contact Oauth2 Access Token
190
+ * @param string $fileName - Name of the file
191
+ * @param string $fileLocation - Path to the location of the file on the server
192
+ * @throws IllegalArgumentException if file type is not one listed in the description
193
+ * @param string $description - Description of the file
194
+ * @param string $source - Source
195
+ * @param string $folderId - Folder ID to upload file to. Set as 0 for no folder.
196
+ * @return string File upload status ID
197
+ * @throws CtctException
198
+ */
199
+ public function uploadFile($accessToken, $fileName, $fileLocation, $description, $source, $folderId) {
200
+ $finfo = finfo_open(FILEINFO_MIME_TYPE);
201
+ $mime = finfo_file($finfo, $fileLocation);
202
+ finfo_close($finfo);
203
+ if ($mime == "image/png") {
204
+ $fileType = "PNG";
205
+ } elseif ($mime == "image/jpeg") {
206
+ $fileType = "JPG";
207
+ } elseif ($mime == "image/gif") {
208
+ $fileType = "GIF";
209
+ } elseif ($mime == "application/pdf") {
210
+ $fileType = "PDF";
211
+ } else {
212
+ throw new IllegalArgumentException(sprintf(Config::get('errors.file_extension'), "PNG, JPG, JPEG, GIF, PDF was " . $mime));
213
+ }
214
+
215
+
216
+ $baseUrl = Config::get('endpoints.base_url') . Config::get('endpoints.library_files');
217
+ $request = new Request('POST', $baseUrl, [
218
+ parent::getHeadersForMultipart($accessToken)
219
+ ]);
220
+
221
+ try {
222
+ $response = parent::getClient()->send($request, [
223
+ 'multipart' => [
224
+ [
225
+ 'folder_id' => $folderId,
226
+ 'file_name' => $fileName,
227
+ 'file_type' => $fileType,
228
+ 'description' => $description,
229
+ 'source' => $source,
230
+ 'data' => fopen($fileLocation, 'r')
231
+ ]
232
+ ]
233
+ ]);
234
+ } catch (TransferException $e) {
235
+ throw parent::convertException($e);
236
+ }
237
+
238
+ return $response->getHeader("Id");
239
+ }
240
+
241
+ /**
242
+ * Creates a new Library folder
243
+ * @param string $accessToken - Constant Contact OAuth2 token
244
+ * @param Folder $folder
245
+ * @return \Ctct\Components\Library\Folder - Newly created folder
246
+ * @throws CtctException
247
+ */
248
+ public function createLibraryFolder($accessToken, Folder $folder) {
249
+ $baseUrl = Config::get('endpoints.base_url') . Config::get('endpoints.library_folders');
250
+
251
+ try {
252
+ $response = parent::sendRequestWithBody($accessToken, "POST", $baseUrl, $folder);
253
+ } catch (TransferException $e) {
254
+ throw parent::convertException($e);
255
+ }
256
+
257
+ $body = json_decode($response->getBody(), true);
258
+ return Folder::create($body);
259
+ }
260
+
261
+ /**
262
+ * Get the status of a File upload
263
+ * @param string $accessToken - Constant Contact OAuth2 token
264
+ * @param string $uploadStatusIds - Single ID or ID's of statuses to check, separated by commas (no spaces)
265
+ * @return FileUploadStatus[] - Array of FileUploadStatus
266
+ * @throws CtctException
267
+ */
268
+ public function getFileUploadStatus($accessToken, $uploadStatusIds) {
269
+ $baseUrl = Config::get('endpoints.base_url') . sprintf(Config::get('endpoints.library_file_upload_status'), $uploadStatusIds);
270
+
271
+ try {
272
+ $response = parent::sendRequestWithoutBody($accessToken, "GET", $baseUrl);
273
+ } catch (TransferException $e) {
274
+ throw parent::convertException($e);
275
+ }
276
+
277
+ $fileUploadStatuses = array();
278
+ foreach (json_decode($response->getBody(), true) as $fileUploadStatus) {
279
+ $fileUploadStatuses[] = FileUploadStatus::create($fileUploadStatus);
280
+ }
281
+ return $fileUploadStatuses;
282
+ }
283
+ }
app/api/Ctct/Services/ListService.php ADDED
@@ -0,0 +1,117 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Ctct\Services;
3
+
4
+ use Ctct\Components\Contacts\ContactList;
5
+ use Ctct\Exceptions\CtctException;
6
+ use Ctct\Util\Config;
7
+ use GuzzleHttp\Exception\TransferException;
8
+
9
+ /**
10
+ * Performs all actions pertaining to Constant Contact Lists
11
+ *
12
+ * @package Services
13
+ * @author Constant Contact
14
+ */
15
+ class ListService extends BaseService {
16
+ /**
17
+ * Get lists within an account
18
+ * @param $accessToken - Constant Contact OAuth2 access token
19
+ * @param array $params - associative array of query parameters and values to append to the request.
20
+ * Allowed parameters include:
21
+ * modified_since - ISO-8601 formatted timestamp.
22
+ * @return array - ContactLists
23
+ * @throws CtctException
24
+ */
25
+ public function getLists($accessToken, Array $params = array()) {
26
+ $baseUrl = Config::get('endpoints.base_url') . Config::get('endpoints.lists');
27
+
28
+ try {
29
+ $response = parent::sendRequestWithoutBody($accessToken, 'GET', $baseUrl, $params);
30
+ } catch (TransferException $e) {
31
+ throw parent::convertException($e);
32
+ }
33
+
34
+ $lists = array();
35
+ foreach (json_decode($response->getBody(), true) as $contact) {
36
+ $lists[] = ContactList::create($contact);
37
+ }
38
+
39
+ return $lists;
40
+ }
41
+
42
+ /**
43
+ * Create a new Contact List
44
+ * @param string $accessToken - Constant Contact OAuth2 access token
45
+ * @param ContactList $list
46
+ * @return ContactList
47
+ * @throws CtctException
48
+ */
49
+ public function addList($accessToken, ContactList $list) {
50
+ $baseUrl = Config::get('endpoints.base_url') . Config::get('endpoints.lists');
51
+
52
+ try {
53
+ $response = parent::sendRequestWithBody($accessToken, 'POST', $baseUrl, $list);
54
+ } catch (TransferException $e) {
55
+ throw parent::convertException($e);
56
+ }
57
+
58
+ return ContactList::create(json_decode($response->getBody(), true));
59
+ }
60
+
61
+ /**
62
+ * Update a Contact List
63
+ * @param string $accessToken - Constant Contact OAuth2 access token
64
+ * @param ContactList $list - ContactList to be updated
65
+ * @return ContactList
66
+ * @throws CtctException
67
+ */
68
+ public function updateList($accessToken, ContactList $list) {
69
+ $baseUrl = Config::get('endpoints.base_url') . sprintf(Config::get('endpoints.list'), $list->id);
70
+
71
+ try {
72
+ $response = parent::sendRequestWithBody($accessToken, 'PUT', $baseUrl, $list);
73
+ } catch (TransferException $e) {
74
+ throw parent::convertException($e);
75
+ }
76
+
77
+ return ContactList::create(json_decode($response->getBody(), true));
78
+ }
79
+
80
+ /**
81
+ * Delete a Contact List
82
+ * @param string $accessToken - Constant Contact OAuth2 access token
83
+ * @param $listId - list id
84
+ * @return ContactList
85
+ * @throws CtctException
86
+ */
87
+ public function deleteList($accessToken, $listId) {
88
+ $baseUrl = Config::get('endpoints.base_url') . sprintf(Config::get('endpoints.list'), $listId);
89
+
90
+ try {
91
+ $response = parent::sendRequestWithoutBody($accessToken, 'DELETE', $baseUrl);
92
+ } catch (TransferException $e) {
93
+ throw parent::convertException($e);
94
+ }
95
+
96
+ return ($response->getStatusCode() == 204) ? true : false;
97
+ }
98
+
99
+ /**
100
+ * Get an individual contact list
101
+ * @param $accessToken - Constant Contact OAuth2 access token
102
+ * @param $listId - list id
103
+ * @return ContactList
104
+ * @throws CtctException
105
+ */
106
+ public function getList($accessToken, $listId) {
107
+ $baseUrl = Config::get('endpoints.base_url') . sprintf(Config::get('endpoints.list'), $listId);
108
+
109
+ try {
110
+ $response = parent::sendRequestWithoutBody($accessToken, 'GET', $baseUrl);
111
+ } catch (TransferException $e) {
112
+ throw parent::convertException($e);
113
+ }
114
+
115
+ return ContactList::create(json_decode($response->getBody(), true));
116
+ }
117
+ }
app/api/Ctct/SplClassLoader.php ADDED
@@ -0,0 +1,130 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Ctct;
3
+
4
+ /**
5
+ * SplClassLoader implementation that implements the technical interoperability
6
+ * standards for PHP 5.3 namespaces and class names.
7
+ *
8
+ * http://groups.google.com/group/php-standards/web/final-proposal
9
+ *
10
+ * // Example which loads classes for the Doctrine Common package in the
11
+ * // Doctrine\Common namespace.
12
+ * $classLoader = new SplClassLoader('Doctrine\Common', '/path/to/doctrine');
13
+ * $classLoader->register();
14
+ *
15
+ * @author Jonathan H. Wage <jonwage@gmail.com>
16
+ * @author Roman S. Borschel <roman@code-factory.org>
17
+ * @author Matthew Weier O'Phinney <matthew@zend.com>
18
+ * @author Kris Wallsmith <kris.wallsmith@gmail.com>
19
+ * @author Fabien Potencier <fabien.potencier@symfony-project.org>
20
+ */
21
+
22
+ class SplClassLoader {
23
+ private $fileExtension = '.php';
24
+ private $namespace;
25
+ private $includePath;
26
+ private $namespaceSeparator = '\\';
27
+
28
+ /**
29
+ * Creates a new <tt>SplClassLoader</tt> that loads classes of the
30
+ * specified namespace.
31
+ *
32
+ * @param string $ns The namespace to use.
33
+ * @param string $includePath The include path to use.
34
+ */
35
+ public function __construct($ns = null, $includePath = null) {
36
+ $this->namespace = $ns;
37
+ $this->includePath = $includePath;
38
+ }
39
+
40
+ /**
41
+ * Gets the namespace separator used by classes in the namespace of this class loader.
42
+ *
43
+ * @return string $namespaceSeparator
44
+ */
45
+ public function getNamespaceSeparator() {
46
+ return $this->namespaceSeparator;
47
+ }
48
+
49
+ /**
50
+ * Sets the namespace separator used by classes in the namespace of this class loader.
51
+ *
52
+ * @param string $sep The separator to use.
53
+ */
54
+ public function setNamespaceSeparator($sep) {
55
+ $this->namespaceSeparator = $sep;
56
+ }
57
+
58
+ /**
59
+ * Gets the base include path for all class files in the namespace of this class loader.
60
+ *
61
+ * @return string $includePath
62
+ */
63
+ public function getIncludePath() {
64
+ return $this->includePath;
65
+ }
66
+
67
+ /**
68
+ * Sets the base include path for all class files in the namespace of this class loader.
69
+ *
70
+ * @param string $includePath
71
+ */
72
+ public function setIncludePath($includePath) {
73
+ $this->includePath = $includePath;
74
+ }
75
+
76
+ /**
77
+ * Gets the file extension of class files in the namespace of this class loader.
78
+ *
79
+ * @return string $fileExtension
80
+ */
81
+ public function getFileExtension() {
82
+ return $this->fileExtension;
83
+ }
84
+
85
+ /**
86
+ * Sets the file extension of class files in the namespace of this class loader.
87
+ *
88
+ * @param string $fileExtension
89
+ */
90
+ public function setFileExtension($fileExtension) {
91
+ $this->fileExtension = $fileExtension;
92
+ }
93
+
94
+ /**
95
+ * Installs this class loader on the SPL autoload stack.
96
+ */
97
+ public function register() {
98
+ spl_autoload_register(array($this, 'loadClass'));
99
+ }
100
+
101
+ /**
102
+ * Uninstalls this class loader from the SPL autoloader stack.
103
+ */
104
+ public function unregister() {
105
+ spl_autoload_unregister(array($this, 'loadClass'));
106
+ }
107
+
108
+ /**
109
+ * Loads the given class or interface.
110
+ *
111
+ * @param string $className The name of the class to load.
112
+ * @return void
113
+ */
114
+ public function loadClass($className) {
115
+ if (null === $this->namespace || $this->namespace . $this->namespaceSeparator ===
116
+ substr($className, 0, strlen($this->namespace . $this->namespaceSeparator))
117
+ ) {
118
+ $fileName = '';
119
+ if (false !== ($lastNsPos = strripos($className, $this->namespaceSeparator))) {
120
+ $namespace = substr($className, 0, $lastNsPos);
121
+ $className = substr($className, $lastNsPos + 1);
122
+ $fileName = str_replace($this->namespaceSeparator, DIRECTORY_SEPARATOR, $namespace)
123
+ . DIRECTORY_SEPARATOR;
124
+ }
125
+ $fileName .= str_replace('_', DIRECTORY_SEPARATOR, $className) . $this->fileExtension;
126
+
127
+ require ($this->includePath !== null ? $this->includePath . DIRECTORY_SEPARATOR : '') . $fileName;
128
+ }
129
+ }
130
+ }
app/api/Ctct/Util/Config.php ADDED
@@ -0,0 +1,169 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Ctct\Util;
3
+
4
+ /**
5
+ * Configuration class to hold endpoints, urls, errors messages etc.
6
+ *
7
+ * @package Util
8
+ * @author Constant Contact
9
+ */
10
+ class Config {
11
+ /**
12
+ * @var array - array of configuration properties
13
+ */
14
+ private static $props = array(
15
+ /**
16
+ * REST endpoints
17
+ */
18
+ 'endpoints' => array(
19
+ 'base_url' => 'https://api.constantcontact.com/v2/',
20
+ 'account_verified_addresses' => 'account/verifiedemailaddresses',
21
+ 'account_info' => 'account/info',
22
+ 'activity' => 'activities/%s',
23
+ 'activities' => 'activities',
24
+ 'export_contacts_activity' => 'activities/exportcontacts',
25
+ 'clear_lists_activity' => 'activities/clearlists',
26
+ 'remove_from_lists_activity' => 'activities/removefromlists',
27
+ 'add_contacts_activity' => 'activities/addcontacts',
28
+ 'contact' => 'contacts/%s',
29
+ 'contacts' => 'contacts',
30
+ 'lists' => 'lists',
31
+ 'list' => 'lists/%s',
32
+ 'list_contacts' => 'lists/%s/contacts',
33
+ 'contact_lists' => 'contacts/%s/lists',
34
+ 'contact_list' => 'contacts/%s/lists/%s',
35
+ 'campaigns' => 'emailmarketing/campaigns',
36
+ 'campaign' => 'emailmarketing/campaigns/%s',
37
+ 'campaign_schedules' => 'emailmarketing/campaigns/%s/schedules',
38
+ 'campaign_schedule' => 'emailmarketing/campaigns/%s/schedules/%s',
39
+ 'campaign_test_sends' => 'emailmarketing/campaigns/%s/tests',
40
+ 'campaign_preview' => 'emailmarketing/campaigns/%s/preview',
41
+ 'campaign_tracking_summary' => 'emailmarketing/campaigns/%s/tracking/reports/summary',
42
+ 'campaign_tracking_bounces' => 'emailmarketing/campaigns/%s/tracking/bounces',
43
+ 'campaign_tracking_clicks' => 'emailmarketing/campaigns/%s/tracking/clicks',
44
+ 'campaign_tracking_forwards' => 'emailmarketing/campaigns/%s/tracking/forwards',
45
+ 'campaign_tracking_opens' => 'emailmarketing/campaigns/%s/tracking/opens',
46
+ 'campaign_tracking_sends' => 'emailmarketing/campaigns/%s/tracking/sends',
47
+ 'campaign_tracking_unsubscribes' => 'emailmarketing/campaigns/%s/tracking/unsubscribes',
48
+ 'campaign_tracking_link' => 'emailmarketing/campaigns/%s/tracking/clicks/%s',
49
+ 'contact_tracking_summary' => 'contacts/%s/tracking/reports/summary',
50
+ 'contact_tracking_bounces' => 'contacts/%s/tracking/bounces',
51
+ 'contact_tracking_clicks' => 'contacts/%s/tracking/clicks',
52
+ 'contact_tracking_forwards' => 'contacts/%s/tracking/forwards',
53
+ 'contact_tracking_opens' => 'contacts/%s/tracking/opens',
54
+ 'contact_tracking_sends' => 'contacts/%s/tracking/sends',
55
+ 'contact_tracking_unsubscribes' => 'contacts/%s/tracking/unsubscribes',
56
+ 'contact_tracking_link' => 'contacts/%s/tracking/clicks/%s',
57
+ 'events' => 'eventspot/events',
58
+ 'event' => 'eventspot/events/%s',
59
+ 'event_fees' => 'eventspot/events/%s/fees',
60
+ 'event_fee' => 'eventspot/events/%s/fees/%s',
61
+ 'event_registrants' => 'eventspot/events/%s/registrants',
62
+ 'event_registrant' => 'eventspot/events/%s/registrants/%s',
63
+ 'event_promocodes' => 'eventspot/events/%s/promocodes',
64
+ 'event_promocode' => 'eventspot/events/%s/promocodes/%s',
65
+ 'event_items' => 'eventspot/events/%s/items',
66
+ 'event_item' => 'eventspot/events/%s/items/%s',
67
+ 'event_item_attributes' => 'eventspot/events/%s/items/%s/attributes',
68
+ 'event_item_attribute' => 'eventspot/events/%s/items/%s/attributes/%s',
69
+ 'library_files' => 'library/files',
70
+ 'library_file' => 'library/files/%s',
71
+ 'library_folders' => 'library/folders',
72
+ 'library_folder' => 'library/folders/%s',
73
+ 'library_files_by_folder' => 'library/folders/%s/files',
74
+ 'library_file_upload_status' => 'library/files/uploadstatus/%s'
75
+ ),
76
+ /**
77
+ * Column names used with bulk activities
78
+ */
79
+ 'activities_columns' => array(
80
+ 'email' => 'EMAIL',
81
+ 'first_name' => 'FIRST NAME',
82
+ 'last_name' => 'LAST NAME',
83
+ 'birthday_day' => 'BIRTHDAY_DAY',
84
+ 'birthday_month' => 'BIRTHDAY_MONTH',
85
+ 'anniversary' => 'ANNIVERSARY',
86
+ 'job_title' => 'JOB TITLE',
87
+ 'company_name' => 'COMPANY NAME',
88
+ 'work_phone' => 'WORK PHONE',
89
+ 'home_phone' => 'HOME PHONE',
90
+ 'address1' => 'ADDRESS LINE 1',
91
+ 'address2' => 'ADDRESS LINE 2',
92
+ 'address3' => 'ADDRESS LINE 3',
93
+ 'city' => 'CITY',
94
+ 'state' => 'STATE',
95
+ 'state_province' => 'US STATE/CA PROVINCE',
96
+ 'country' => 'COUNTRY',
97
+ 'postal_code' => 'ZIP/POSTAL CODE',
98
+ 'sub_postal_code' => 'SUB ZIP/POSTAL CODE',
99
+ 'custom_field_1' => 'CUSTOM FIELD 1',
100
+ 'custom_field_2' => 'CUSTOM FIELD 2',
101
+ 'custom_field_3' => 'CUSTOM FIELD 3',
102
+ 'custom_field_4' => 'CUSTOM FIELD 4',
103
+ 'custom_field_5' => 'CUSTOM FIELD 5',
104
+ 'custom_field_6' => 'CUSTOM FIELD 6',
105
+ 'custom_field_7' => 'CUSTOM FIELD 7',
106
+ 'custom_field_8' => 'CUSTOM FIELD 8',
107
+ 'custom_field_9' => 'CUSTOM FIELD 9',
108
+ 'custom_field_10' => 'CUSTOM FIELD 10',
109
+ 'custom_field_11' => 'CUSTOM FIELD 11',
110
+ 'custom_field_12' => 'CUSTOM FIELD 12',
111
+ 'custom_field_13' => 'CUSTOM FIELD 13',
112
+ 'custom_field_14' => 'CUSTOM FIELD 14',
113
+ 'custom_field_15' => 'CUSTOM FIELD 15',
114
+ ),
115
+ /**
116
+ * OAuth2 Authorization related configuration options
117
+ */
118
+ 'auth' => array(
119
+ 'base_url' => 'https://oauth2.constantcontact.com/oauth2/',
120
+ 'response_type_code' => 'code',
121
+ 'response_type_token' => 'token',
122
+ 'authorization_code_grant_type' => 'authorization_code',
123
+ 'authorization_endpoint' => 'oauth/siteowner/authorize',
124
+ 'token_endpoint' => 'oauth/token',
125
+ 'token_info' => 'tokeninfo.htm'
126
+ ),
127
+ /**
128
+ * Errors to be returned for various exceptions
129
+ */
130
+ 'errors' => array(
131
+ 'id_or_object' => 'Only an id or %s object are allowed for this method.',
132
+ 'file_extension' => 'Only file extensions of the following are allowed: %s'
133
+ ),
134
+
135
+ /**
136
+ * Setting the version fo the application used in Rest Calls when setting the version header
137
+ */
138
+ 'settings' => array(
139
+ 'version' => '3.x.x'
140
+ ),
141
+ );
142
+
143
+ /**
144
+ * Get a configuration property given a specified location, example usage: Config::get('auth.token_endpoint')
145
+ * @param $index - location of the property to obtain
146
+ * @return string
147
+ */
148
+ public static function get($index) {
149
+ $index = explode('.', $index);
150
+ return self::getValue($index, self::$props);
151
+ }
152
+
153
+ /**
154
+ * Navigate through a config array looking for a particular index
155
+ * @param array $index The index sequence we are navigating down
156
+ * @param array $value The portion of the config array to process
157
+ * @return mixed
158
+ */
159
+ private static function getValue($index, $value) {
160
+ if (is_array($index) && count($index)) {
161
+ $current_index = array_shift($index);
162
+ }
163
+ if (is_array($index) && count($index) && is_array($value[$current_index]) && count($value[$current_index])) {
164
+ return self::getValue($index, $value[$current_index]);
165
+ } else {
166
+ return $value[$current_index];
167
+ }
168
+ }
169
+ }
app/api/Ctct/WebHooks/CTCTWebhookUtil.php ADDED
@@ -0,0 +1,91 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Ctct\WebHooks;
3
+
4
+ use Ctct\Exceptions\CtctException;
5
+
6
+ /**
7
+ * Main Webhook Utility class.<br/>
8
+ * This is meant to be used by users to validate and parse Webhooks received from ConstantContact.<br/>
9
+ *
10
+ * @package WebHooks
11
+ * @author Constant Contact
12
+ */
13
+ class CTCTWebhookUtil {
14
+ /**
15
+ * The client secret associated with the api key
16
+ */
17
+ private $clientSecret = '';
18
+
19
+ /**
20
+ * Constructor that creates a validation Object for WebHooks.
21
+ *
22
+ * @param string $clientSecret - The client secret associated with the api key
23
+ * @return CTCTWebhookUtil
24
+ */
25
+ function __construct($clientSecret = '') {
26
+ $this->setClientSecret($clientSecret);
27
+ }
28
+
29
+ /**
30
+ * Get Billing Change Notification.<br/>
31
+ *
32
+ * Validates and parses the bodyMessage into
33
+ *
34
+ * @param xCtctHmacSHA256 The value in the x-ctct-hmac-sha256 header.
35
+ * @param bodyMessage The body message from the POST received from ConstantContact in Webhook callback.
36
+ * @return The object corresponding to bodyMessage in case of success; an exception is thrown otherwise.
37
+ * @throws CtctException Thrown when :
38
+ * <ul>
39
+ * <li>message encryption does not correspond with x-ctct-hmac-sha256 header value;</li>
40
+ * <li>or an error is raised when parsing the bodyMessage.</li>
41
+ * </ul>
42
+ * <p/>
43
+ */
44
+ public function getBillingChangeNotification($xCtctHmacSHA256, $bodyMessage) {
45
+ if ($this->isValidWebhook($xCtctHmacSHA256, $bodyMessage)) {
46
+ return json_decode($bodyMessage);
47
+ } else {
48
+ throw new CtctException("Invalid WebHook");
49
+ }
50
+ }
51
+
52
+ /**
53
+ * Check if a Webhook message is valid or not.<br/>
54
+ *
55
+ * @param $xCtctHmacSHA256
56
+ * @param $bodyMessage
57
+ * @return true if in case of success; false if the Webhook is invalid.
58
+ *
59
+ * @throws CtctException
60
+ * @internal param The $xCtctHmacSHA256 value in the x-ctct-hmac-sha256 header.
61
+ * @internal param The $bodyMessage body message from the POST received from ConstantContact in Webhook callback.
62
+ */
63
+ public function isValidWebhook($xCtctHmacSHA256, $bodyMessage) {
64
+ if ($this->getClientSecret() == null) {
65
+ throw new CtctException("NO_CLIENT_SECRET");
66
+ }
67
+ $encodedString = hash_hmac("sha256", $bodyMessage, $this->clientSecret);
68
+
69
+ return ($encodedString == $xCtctHmacSHA256) ? true : false;
70
+ }
71
+
72
+ /**
73
+ * CTCTWebhookUtil::getClientSecret()
74
+ *
75
+ * @return string - the secret API key
76
+ */
77
+ public function getClientSecret() {
78
+ return $this->clientSecret;
79
+ }
80
+
81
+ /**
82
+ * CTCTWebhookUtil::setClientSecret()
83
+ * Set the clientSecret
84
+ *
85
+ * @param string $clientSecret - The client secret associated with the api key
86
+ * @return void
87
+ */
88
+ public function setClientSecret($clientSecret) {
89
+ $this->clientSecret = $clientSecret;
90
+ }
91
+ }
app/api/Ctct/autoload.php ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <?php
2
+ require_once('SplClassLoader.php');
3
+
4
+ // Load the Ctct namespace
5
+ $loader = new \Ctct\SplClassLoader('Ctct', dirname(__DIR__));
6
+ $loader->register();
app/api/Ctct/vendor.zip ADDED
Binary file
app/api/Ctct/vendor/autoload.php ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // autoload.php @generated by Composer
4
+
5
+ require_once __DIR__ . '/composer' . '/autoload_real.php';
6
+
7
+ return ComposerAutoloaderInit7a1f4c71e38d898b78a6f5bf4f3018bd::getLoader();
app/api/Ctct/vendor/composer/ClassLoader.php ADDED
@@ -0,0 +1,413 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * This file is part of Composer.
5
+ *
6
+ * (c) Nils Adermann <naderman@naderman.de>
7
+ * Jordi Boggiano <j.boggiano@seld.be>
8
+ *
9
+ * For the full copyright and license information, please view the LICENSE
10
+ * file that was distributed with this source code.
11
+ */
12
+
13
+ namespace Composer\Autoload;
14
+
15
+ /**
16
+ * ClassLoader implements a PSR-0, PSR-4 and classmap class loader.
17
+ *
18
+ * $loader = new \Composer\Autoload\ClassLoader();
19
+ *
20
+ * // register classes with namespaces
21
+ * $loader->add('Symfony\Component', __DIR__.'/component');
22
+ * $loader->add('Symfony', __DIR__.'/framework');
23
+ *
24
+ * // activate the autoloader
25
+ * $loader->register();
26
+ *
27
+ * // to enable searching the include path (eg. for PEAR packages)
28
+ * $loader->setUseIncludePath(true);
29
+ *
30
+ * In this example, if you try to use a class in the Symfony\Component
31
+ * namespace or one of its children (Symfony\Component\Console for instance),
32
+ * the autoloader will first look for the class under the component/
33
+ * directory, and it will then fallback to the framework/ directory if not
34
+ * found before giving up.
35
+ *
36
+ * This class is loosely based on the Symfony UniversalClassLoader.
37
+ *
38
+ * @author Fabien Potencier <fabien@symfony.com>
39
+ * @author Jordi Boggiano <j.boggiano@seld.be>
40
+ * @see http://www.php-fig.org/psr/psr-0/
41
+ * @see http://www.php-fig.org/psr/psr-4/
42
+ */
43
+ class ClassLoader
44
+ {
45
+ // PSR-4
46
+ private $prefixLengthsPsr4 = array();
47
+ private $prefixDirsPsr4 = array();
48
+ private $fallbackDirsPsr4 = array();
49
+
50
+ // PSR-0
51
+ private $prefixesPsr0 = array();
52
+ private $fallbackDirsPsr0 = array();
53
+
54
+ private $useIncludePath = false;
55
+ private $classMap = array();
56
+
57
+ private $classMapAuthoritative = false;
58
+
59
+ public function getPrefixes()
60
+ {
61
+ if (!empty($this->prefixesPsr0)) {
62
+ return call_user_func_array('array_merge', $this->prefixesPsr0);
63
+ }
64
+
65
+ return array();
66
+ }
67
+
68
+ public function getPrefixesPsr4()
69
+ {
70
+ return $this->prefixDirsPsr4;
71
+ }
72
+
73
+ public function getFallbackDirs()
74
+ {
75
+ return $this->fallbackDirsPsr0;
76
+ }
77
+
78
+ public function getFallbackDirsPsr4()
79
+ {
80
+ return $this->fallbackDirsPsr4;
81
+ }
82
+
83
+ public function getClassMap()
84
+ {
85
+ return $this->classMap;
86
+ }
87
+
88
+ /**
89
+ * @param array $classMap Class to filename map
90
+ */
91
+ public function addClassMap(array $classMap)
92
+ {
93
+ if ($this->classMap) {
94
+ $this->classMap = array_merge($this->classMap, $classMap);
95
+ } else {
96
+ $this->classMap = $classMap;
97
+ }
98
+ }
99
+
100
+ /**
101
+ * Registers a set of PSR-0 directories for a given prefix, either
102
+ * appending or prepending to the ones previously set for this prefix.
103
+ *
104
+ * @param string $prefix The prefix
105
+ * @param array|string $paths The PSR-0 root directories
106
+ * @param bool $prepend Whether to prepend the directories
107
+ */
108
+ public function add($prefix, $paths, $prepend = false)
109
+ {
110
+ if (!$prefix) {
111
+ if ($prepend) {
112
+ $this->fallbackDirsPsr0 = array_merge(
113
+ (array) $paths,
114
+ $this->fallbackDirsPsr0
115
+ );
116
+ } else {
117
+ $this->fallbackDirsPsr0 = array_merge(
118
+ $this->fallbackDirsPsr0,
119
+ (array) $paths
120
+ );
121
+ }
122
+
123
+ return;
124
+ }
125
+
126
+ $first = $prefix[0];
127
+ if (!isset($this->prefixesPsr0[$first][$prefix])) {
128
+ $this->prefixesPsr0[$first][$prefix] = (array) $paths;
129
+
130
+ return;
131
+ }
132
+ if ($prepend) {
133
+ $this->prefixesPsr0[$first][$prefix] = array_merge(
134
+ (array) $paths,
135
+ $this->prefixesPsr0[$first][$prefix]
136
+ );
137
+ } else {
138
+ $this->prefixesPsr0[$first][$prefix] = array_merge(
139
+ $this->prefixesPsr0[$first][$prefix],
140
+ (array) $paths
141
+ );
142
+ }
143
+ }
144
+
145
+ /**
146
+ * Registers a set of PSR-4 directories for a given namespace, either
147
+ * appending or prepending to the ones previously set for this namespace.
148
+ *
149
+ * @param string $prefix The prefix/namespace, with trailing '\\'
150
+ * @param array|string $paths The PSR-4 base directories
151
+ * @param bool $prepend Whether to prepend the directories
152
+ *
153
+ * @throws \InvalidArgumentException
154
+ */
155
+ public function addPsr4($prefix, $paths, $prepend = false)
156
+ {
157
+ if (!$prefix) {
158
+ // Register directories for the root namespace.
159
+ if ($prepend) {
160
+ $this->fallbackDirsPsr4 = array_merge(
161
+ (array) $paths,
162
+ $this->fallbackDirsPsr4
163
+ );
164
+ } else {
165
+ $this->fallbackDirsPsr4 = array_merge(
166
+ $this->fallbackDirsPsr4,
167
+ (array) $paths
168
+ );
169
+ }
170
+ } elseif (!isset($this->prefixDirsPsr4[$prefix])) {
171
+ // Register directories for a new namespace.
172
+ $length = strlen($prefix);
173
+ if ('\\' !== $prefix[$length - 1]) {
174
+ throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
175
+ }
176
+ $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
177
+ $this->prefixDirsPsr4[$prefix] = (array) $paths;
178
+ } elseif ($prepend) {
179
+ // Prepend directories for an already registered namespace.
180
+ $this->prefixDirsPsr4[$prefix] = array_merge(
181
+ (array) $paths,
182
+ $this->prefixDirsPsr4[$prefix]
183
+ );
184
+ } else {
185
+ // Append directories for an already registered namespace.
186
+ $this->prefixDirsPsr4[$prefix] = array_merge(
187
+ $this->prefixDirsPsr4[$prefix],
188
+ (array) $paths
189
+ );
190
+ }
191
+ }
192
+
193
+ /**
194
+ * Registers a set of PSR-0 directories for a given prefix,
195
+ * replacing any others previously set for this prefix.
196
+ *
197
+ * @param string $prefix The prefix
198
+ * @param array|string $paths The PSR-0 base directories
199
+ */
200
+ public function set($prefix, $paths)
201
+ {
202
+ if (!$prefix) {
203
+ $this->fallbackDirsPsr0 = (array) $paths;
204
+ } else {
205
+ $this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths;
206
+ }
207
+ }
208
+
209
+ /**
210
+ * Registers a set of PSR-4 directories for a given namespace,
211
+ * replacing any others previously set for this namespace.
212
+ *
213
+ * @param string $prefix The prefix/namespace, with trailing '\\'
214
+ * @param array|string $paths The PSR-4 base directories
215
+ *
216
+ * @throws \InvalidArgumentException
217
+ */
218
+ public function setPsr4($prefix, $paths)
219
+ {
220
+ if (!$prefix) {
221
+ $this->fallbackDirsPsr4 = (array) $paths;
222
+ } else {
223
+ $length = strlen($prefix);
224
+ if ('\\' !== $prefix[$length - 1]) {
225
+ throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
226
+ }
227
+ $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
228
+ $this->prefixDirsPsr4[$prefix] = (array) $paths;
229
+ }
230
+ }
231
+
232
+ /**
233
+ * Turns on searching the include path for class files.
234
+ *
235
+ * @param bool $useIncludePath
236
+ */
237
+ public function setUseIncludePath($useIncludePath)
238
+ {
239
+ $this->useIncludePath = $useIncludePath;
240
+ }
241
+
242
+ /**
243
+ * Can be used to check if the autoloader uses the include path to check
244
+ * for classes.
245
+ *
246
+ * @return bool
247
+ */
248
+ public function getUseIncludePath()
249
+ {
250
+ return $this->useIncludePath;
251
+ }
252
+
253
+ /**
254
+ * Turns off searching the prefix and fallback directories for classes
255
+ * that have not been registered with the class map.
256
+ *
257
+ * @param bool $classMapAuthoritative
258
+ */
259
+ public function setClassMapAuthoritative($classMapAuthoritative)
260
+ {
261
+ $this->classMapAuthoritative = $classMapAuthoritative;
262
+ }
263
+
264
+ /**
265
+ * Should class lookup fail if not found in the current class map?
266
+ *
267
+ * @return bool
268
+ */
269
+ public function isClassMapAuthoritative()
270
+ {
271
+ return $this->classMapAuthoritative;
272
+ }
273
+
274
+ /**
275
+ * Registers this instance as an autoloader.
276
+ *
277
+ * @param bool $prepend Whether to prepend the autoloader or not
278
+ */
279
+ public function register($prepend = false)
280
+ {
281
+ spl_autoload_register(array($this, 'loadClass'), true, $prepend);
282
+ }
283
+
284
+ /**
285
+ * Unregisters this instance as an autoloader.
286
+ */
287
+ public function unregister()
288
+ {
289
+ spl_autoload_unregister(array($this, 'loadClass'));
290
+ }
291
+
292
+ /**
293
+ * Loads the given class or interface.
294
+ *
295
+ * @param string $class The name of the class
296
+ * @return bool|null True if loaded, null otherwise
297
+ */
298
+ public function loadClass($class)
299
+ {
300
+ if ($file = $this->findFile($class)) {
301
+ includeFile($file);
302
+
303
+ return true;
304
+ }
305
+ }
306
+
307
+ /**
308
+ * Finds the path to the file where the class is defined.
309
+ *
310
+ * @param string $class The name of the class
311
+ *
312
+ * @return string|false The path if found, false otherwise
313
+ */
314
+ public function findFile($class)
315
+ {
316
+ // work around for PHP 5.3.0 - 5.3.2 https://bugs.php.net/50731
317
+ if ('\\' == $class[0]) {
318
+ $class = substr($class, 1);
319
+ }
320
+
321
+ // class map lookup
322
+ if (isset($this->classMap[$class])) {
323
+ return $this->classMap[$class];
324
+ }
325
+ if ($this->classMapAuthoritative) {
326
+ return false;
327
+ }
328
+
329
+ $file = $this->findFileWithExtension($class, '.php');
330
+
331
+ // Search for Hack files if we are running on HHVM
332
+ if ($file === null && defined('HHVM_VERSION')) {
333
+ $file = $this->findFileWithExtension($class, '.hh');
334
+ }
335
+
336
+ if ($file === null) {
337
+ // Remember that this class does not exist.
338
+ return $this->classMap[$class] = false;
339
+ }
340
+
341
+ return $file;
342
+ }
343
+
344
+ private function findFileWithExtension($class, $ext)
345
+ {
346
+ // PSR-4 lookup
347
+ $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext;
348
+
349
+ $first = $class[0];
350
+ if (isset($this->prefixLengthsPsr4[$first])) {
351
+ foreach ($this->prefixLengthsPsr4[$first] as $prefix => $length) {
352
+ if (0 === strpos($class, $prefix)) {
353
+ foreach ($this->prefixDirsPsr4[$prefix] as $dir) {
354
+ if (file_exists($file = $dir . DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $length))) {
355
+ return $file;
356
+ }
357
+ }
358
+ }
359
+ }
360
+ }
361
+
362
+ // PSR-4 fallback dirs
363
+ foreach ($this->fallbackDirsPsr4 as $dir) {
364
+ if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) {
365
+ return $file;
366
+ }
367
+ }
368
+
369
+ // PSR-0 lookup
370
+ if (false !== $pos = strrpos($class, '\\')) {
371
+ // namespaced class name
372
+ $logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1)
373
+ . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR);
374
+ } else {
375
+ // PEAR-like class name
376
+ $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext;
377
+ }
378
+
379
+ if (isset($this->prefixesPsr0[$first])) {
380
+ foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) {
381
+ if (0 === strpos($class, $prefix)) {
382
+ foreach ($dirs as $dir) {
383
+ if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
384
+ return $file;
385
+ }
386
+ }
387
+ }
388
+ }
389
+ }
390
+
391
+ // PSR-0 fallback dirs
392
+ foreach ($this->fallbackDirsPsr0 as $dir) {
393
+ if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
394
+ return $file;
395
+ }
396
+ }
397
+
398
+ // PSR-0 include paths.
399
+ if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) {
400
+ return $file;
401
+ }
402
+ }
403
+ }
404
+
405
+ /**
406
+ * Scope isolated include.
407
+ *
408
+ * Prevents access to $this/self from included files.
409
+ */
410
+ function includeFile($file)
411
+ {
412
+ include $file;
413
+ }
app/api/Ctct/vendor/composer/LICENSE ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ Copyright (c) 2015 Nils Adermann, Jordi Boggiano
3
+
4
+ Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ of this software and associated documentation files (the "Software"), to deal
6
+ in the Software without restriction, including without limitation the rights
7
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the Software is furnished
9
+ to do so, subject to the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be included in all
12
+ copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
+ THE SOFTWARE.
21
+
app/api/Ctct/vendor/composer/autoload_classmap.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // autoload_classmap.php @generated by Composer
4
+
5
+ $vendorDir = dirname(dirname(__FILE__));
6
+ $baseDir = dirname($vendorDir);
7
+
8
+ return array(
9
+ );
app/api/Ctct/vendor/composer/autoload_files.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // autoload_files.php @generated by Composer
4
+
5
+ $vendorDir = dirname(dirname(__FILE__));
6
+ $baseDir = dirname($vendorDir);
7
+
8
+ return array(
9
+ 'c964ee0ededf28c96ebd9db5099ef910' => $vendorDir . '/guzzlehttp/promises/src/functions_include.php',
10
+ 'a0edc8309cc5e1d60e3047b5df6b7052' => $vendorDir . '/guzzlehttp/psr7/src/functions_include.php',
11
+ '37a3dc5111fe8f707ab4c132ef1dbc62' => $vendorDir . '/guzzlehttp/guzzle/src/functions_include.php',
12
+ );
app/api/Ctct/vendor/composer/autoload_namespaces.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // autoload_namespaces.php @generated by Composer
4
+
5
+ $vendorDir = dirname(dirname(__FILE__));
6
+ $baseDir = dirname($vendorDir);
7
+
8
+ return array(
9
+ 'Ctct' => array($vendorDir . '/constantcontact/constantcontact/src'),
10
+ );
app/api/Ctct/vendor/composer/autoload_psr4.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // autoload_psr4.php @generated by Composer
4
+
5
+ $vendorDir = dirname(dirname(__FILE__));
6
+ $baseDir = dirname($vendorDir);
7
+
8
+ return array(
9
+ 'Psr\\Http\\Message\\' => array($vendorDir . '/psr/http-message/src'),
10
+ 'GuzzleHttp\\Psr7\\' => array($vendorDir . '/guzzlehttp/psr7/src'),
11
+ 'GuzzleHttp\\Promise\\' => array($vendorDir . '/guzzlehttp/promises/src'),
12
+ 'GuzzleHttp\\' => array($vendorDir . '/guzzlehttp/guzzle/src'),
13
+ );
app/api/Ctct/vendor/composer/autoload_real.php ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // autoload_real.php @generated by Composer
4
+
5
+ class ComposerAutoloaderInit7a1f4c71e38d898b78a6f5bf4f3018bd
6
+ {
7
+ private static $loader;
8
+
9
+ public static function loadClassLoader($class)
10
+ {
11
+ if ('Composer\Autoload\ClassLoader' === $class) {
12
+ require __DIR__ . '/ClassLoader.php';
13
+ }
14
+ }
15
+
16
+ public static function getLoader()
17
+ {
18
+ if (null !== self::$loader) {
19
+ return self::$loader;
20
+ }
21
+
22
+ spl_autoload_register(array('ComposerAutoloaderInit7a1f4c71e38d898b78a6f5bf4f3018bd', 'loadClassLoader'), true, true);
23
+ self::$loader = $loader = new \Composer\Autoload\ClassLoader();
24
+ spl_autoload_unregister(array('ComposerAutoloaderInit7a1f4c71e38d898b78a6f5bf4f3018bd', 'loadClassLoader'));
25
+
26
+ $map = require __DIR__ . '/autoload_namespaces.php';
27
+ foreach ($map as $namespace => $path) {
28
+ $loader->set($namespace, $path);
29
+ }
30
+
31
+ $map = require __DIR__ . '/autoload_psr4.php';
32
+ foreach ($map as $namespace => $path) {
33
+ $loader->setPsr4($namespace, $path);
34
+ }
35
+
36
+ $classMap = require __DIR__ . '/autoload_classmap.php';
37
+ if ($classMap) {
38
+ $loader->addClassMap($classMap);
39
+ }
40
+
41
+ $loader->register(true);
42
+
43
+ $includeFiles = require __DIR__ . '/autoload_files.php';
44
+ foreach ($includeFiles as $fileIdentifier => $file) {
45
+ composerRequire7a1f4c71e38d898b78a6f5bf4f3018bd($fileIdentifier, $file);
46
+ }
47
+
48
+ return $loader;
49
+ }
50
+ }
51
+
52
+ function composerRequire7a1f4c71e38d898b78a6f5bf4f3018bd($fileIdentifier, $file)
53
+ {
54
+ if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
55
+ require $file;
56
+
57
+ $GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
58
+ }
59
+ }
app/api/Ctct/vendor/composer/installed.json ADDED
@@ -0,0 +1,280 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [
2
+ {
3
+ "name": "guzzlehttp/promises",
4
+ "version": "1.0.3",
5
+ "version_normalized": "1.0.3.0",
6
+ "source": {
7
+ "type": "git",
8
+ "url": "https://github.com/guzzle/promises.git",
9
+ "reference": "b1e1c0d55f8083c71eda2c28c12a228d708294ea"
10
+ },
11
+ "dist": {
12
+ "type": "zip",
13
+ "url": "https://api.github.com/repos/guzzle/promises/zipball/b1e1c0d55f8083c71eda2c28c12a228d708294ea",
14
+ "reference": "b1e1c0d55f8083c71eda2c28c12a228d708294ea",
15
+ "shasum": ""
16
+ },
17
+ "require": {
18
+ "php": ">=5.5.0"
19
+ },
20
+ "require-dev": {
21
+ "phpunit/phpunit": "~4.0"
22
+ },
23
+ "time": "2015-10-15 22:28:00",
24
+ "type": "library",
25
+ "extra": {
26
+ "branch-alias": {
27
+ "dev-master": "1.0-dev"
28
+ }
29
+ },
30
+ "installation-source": "dist",
31
+ "autoload": {
32
+ "psr-4": {
33
+ "GuzzleHttp\\Promise\\": "src/"
34
+ },
35
+ "files": [
36
+ "src/functions_include.php"
37
+ ]
38
+ },
39
+ "notification-url": "https://packagist.org/downloads/",
40
+ "license": [
41
+ "MIT"
42
+ ],
43
+ "authors": [
44
+ {
45
+ "name": "Michael Dowling",
46
+ "email": "mtdowling@gmail.com",
47
+ "homepage": "https://github.com/mtdowling"
48
+ }
49
+ ],
50
+ "description": "Guzzle promises library",
51
+ "keywords": [
52
+ "promise"
53
+ ]
54
+ },
55
+ {
56
+ "name": "psr/http-message",
57
+ "version": "1.0",
58
+ "version_normalized": "1.0.0.0",
59
+ "source": {
60
+ "type": "git",
61
+ "url": "https://github.com/php-fig/http-message.git",
62
+ "reference": "85d63699f0dbedb190bbd4b0d2b9dc707ea4c298"
63
+ },
64
+ "dist": {
65
+ "type": "zip",
66
+ "url": "https://api.github.com/repos/php-fig/http-message/zipball/85d63699f0dbedb190bbd4b0d2b9dc707ea4c298",
67
+ "reference": "85d63699f0dbedb190bbd4b0d2b9dc707ea4c298",
68
+ "shasum": ""
69
+ },
70
+ "require": {
71
+ "php": ">=5.3.0"
72
+ },
73
+ "time": "2015-05-04 20:22:00",
74
+ "type": "library",
75
+ "extra": {
76
+ "branch-alias": {
77
+ "dev-master": "1.0.x-dev"
78
+ }
79
+ },
80
+ "installation-source": "dist",
81
+ "autoload": {
82
+ "psr-4": {
83
+ "Psr\\Http\\Message\\": "src/"
84
+ }
85
+ },
86
+ "notification-url": "https://packagist.org/downloads/",
87
+ "license": [
88
+ "MIT"
89
+ ],
90
+ "authors": [
91
+ {
92
+ "name": "PHP-FIG",
93
+ "homepage": "http://www.php-fig.org/"
94
+ }
95
+ ],
96
+ "description": "Common interface for HTTP messages",
97
+ "keywords": [
98
+ "http",
99
+ "http-message",
100
+ "psr",
101
+ "psr-7",
102
+ "request",
103
+ "response"
104
+ ]
105
+ },
106
+ {
107
+ "name": "guzzlehttp/psr7",
108
+ "version": "1.2.2",
109
+ "version_normalized": "1.2.2.0",
110
+ "source": {
111
+ "type": "git",
112
+ "url": "https://github.com/guzzle/psr7.git",
113
+ "reference": "f5d04bdd2881ac89abde1fb78cc234bce24327bb"
114
+ },
115
+ "dist": {
116
+ "type": "zip",
117
+ "url": "https://api.github.com/repos/guzzle/psr7/zipball/f5d04bdd2881ac89abde1fb78cc234bce24327bb",
118
+ "reference": "f5d04bdd2881ac89abde1fb78cc234bce24327bb",
119
+ "shasum": ""
120
+ },
121
+ "require": {
122
+ "php": ">=5.4.0",
123
+ "psr/http-message": "~1.0"
124
+ },
125
+ "provide": {
126
+ "psr/http-message-implementation": "1.0"
127
+ },
128
+ "require-dev": {
129
+ "phpunit/phpunit": "~4.0"
130
+ },
131
+ "time": "2016-01-23 01:23:02",
132
+ "type": "library",
133
+ "extra": {
134
+ "branch-alias": {
135
+ "dev-master": "1.0-dev"
136
+ }
137
+ },
138
+ "installation-source": "dist",
139
+ "autoload": {
140
+ "psr-4": {
141
+ "GuzzleHttp\\Psr7\\": "src/"
142
+ },
143
+ "files": [
144
+ "src/functions_include.php"
145
+ ]
146
+ },
147
+ "notification-url": "https://packagist.org/downloads/",
148
+ "license": [
149
+ "MIT"
150
+ ],
151
+ "authors": [
152
+ {
153
+ "name": "Michael Dowling",
154
+ "email": "mtdowling@gmail.com",
155
+ "homepage": "https://github.com/mtdowling"
156
+ }
157
+ ],
158
+ "description": "PSR-7 message implementation",
159
+ "keywords": [
160
+ "http",
161
+ "message",
162
+ "stream",
163
+ "uri"
164
+ ]
165
+ },
166
+ {
167
+ "name": "guzzlehttp/guzzle",
168
+ "version": "6.1.1",
169
+ "version_normalized": "6.1.1.0",
170
+ "source": {
171
+ "type": "git",
172
+ "url": "https://github.com/guzzle/guzzle.git",
173
+ "reference": "c6851d6e48f63b69357cbfa55bca116448140e0c"
174
+ },
175
+ "dist": {
176
+ "type": "zip",
177
+ "url": "https://api.github.com/repos/guzzle/guzzle/zipball/c6851d6e48f63b69357cbfa55bca116448140e0c",
178
+ "reference": "c6851d6e48f63b69357cbfa55bca116448140e0c",
179
+ "shasum": ""
180
+ },
181
+ "require": {
182
+ "guzzlehttp/promises": "~1.0",
183
+ "guzzlehttp/psr7": "~1.1",
184
+ "php": ">=5.5.0"
185
+ },
186
+ "require-dev": {
187
+ "ext-curl": "*",
188
+ "phpunit/phpunit": "~4.0",
189
+ "psr/log": "~1.0"
190
+ },
191
+ "time": "2015-11-23 00:47:50",
192
+ "type": "library",
193
+ "extra": {
194
+ "branch-alias": {
195
+ "dev-master": "6.1-dev"
196
+ }
197
+ },
198
+ "installation-source": "dist",
199
+ "autoload": {
200
+ "files": [
201
+ "src/functions_include.php"
202
+ ],
203
+ "psr-4": {
204
+ "GuzzleHttp\\": "src/"
205
+ }
206
+ },
207
+ "notification-url": "https://packagist.org/downloads/",
208
+ "license": [
209
+ "MIT"
210
+ ],
211
+ "authors": [
212
+ {
213
+ "name": "Michael Dowling",
214
+ "email": "mtdowling@gmail.com",
215
+ "homepage": "https://github.com/mtdowling"
216
+ }
217
+ ],
218
+ "description": "Guzzle is a PHP HTTP client library",
219
+ "homepage": "http://guzzlephp.org/",
220
+ "keywords": [
221
+ "client",
222
+ "curl",
223
+ "framework",
224
+ "http",
225
+ "http client",
226
+ "rest",
227
+ "web service"
228
+ ]
229
+ },
230
+ {
231
+ "name": "constantcontact/constantcontact",
232
+ "version": "dev-development",
233
+ "version_normalized": "dev-development",
234
+ "source": {
235
+ "type": "git",
236
+ "url": "https://github.com/constantcontact/php-sdk.git",
237
+ "reference": "5c36b831b775e6607c3c8067ddbd17ccfbee063e"
238
+ },
239
+ "dist": {
240
+ "type": "zip",
241
+ "url": "https://api.github.com/repos/constantcontact/php-sdk/zipball/5c36b831b775e6607c3c8067ddbd17ccfbee063e",
242
+ "reference": "5c36b831b775e6607c3c8067ddbd17ccfbee063e",
243
+ "shasum": ""
244
+ },
245
+ "require": {
246
+ "guzzlehttp/guzzle": "^6.1.1",
247
+ "php": ">=5.5.0"
248
+ },
249
+ "require-dev": {
250
+ "phpunit/phpunit": "4.8.21"
251
+ },
252
+ "time": "2016-02-02 19:41:30",
253
+ "type": "library",
254
+ "installation-source": "source",
255
+ "autoload": {
256
+ "psr-0": {
257
+ "Ctct": "src"
258
+ }
259
+ },
260
+ "notification-url": "https://packagist.org/downloads/",
261
+ "license": [
262
+ "MIT"
263
+ ],
264
+ "authors": [
265
+ {
266
+ "name": "Constant Contact Web Services",
267
+ "email": "webservices@constantcontact.com",
268
+ "homepage": "http://developer.constantcontact.com"
269
+ }
270
+ ],
271
+ "description": "Constant Contact PHP SDK for v2",
272
+ "homepage": "http://developer.constantcontact.com",
273
+ "keywords": [
274
+ "constant contact",
275
+ "constantcontact",
276
+ "ctct",
277
+ "email marketing"
278
+ ]
279
+ }
280
+ ]
app/api/Ctct/vendor/guzzlehttp/guzzle/.travis.yml ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ language: php
2
+
3
+ sudo: false
4
+
5
+ php:
6
+ - 5.5
7
+ - 5.6
8
+ - 7.0
9
+ - hhvm
10
+
11
+ before_script:
12
+ - curl --version
13
+ - composer self-update
14
+ - composer install --no-interaction --prefer-source --dev
15
+ - ~/.nvm/nvm.sh install v0.6.14
16
+ - ~/.nvm/nvm.sh run v0.6.14
17
+
18
+ script: make test
19
+
20
+ matrix:
21
+ allow_failures:
22
+ - php: hhvm
23
+ - php: 7.0
24
+ fast_finish: true
25
+
26
+ before_deploy:
27
+ - make package
28
+
29
+ deploy:
30
+ provider: releases
31
+ api_key:
32
+ secure: UpypqlYgsU68QT/x40YzhHXvzWjFwCNo9d+G8KAdm7U9+blFfcWhV1aMdzugvPMl6woXgvJj7qHq5tAL4v6oswCORhpSBfLgOQVFaica5LiHsvWlAedOhxGmnJqMTwuepjBCxXhs3+I8Kof1n4oUL9gKytXjOVCX/f7XU1HiinU=
33
+ file:
34
+ - build/artifacts/guzzle.phar
35
+ - build/artifacts/guzzle.zip
36
+ on:
37
+ repo: guzzle/guzzle
38
+ tags: true
39
+ all_branches: true
40
+ php: 5.5
app/api/Ctct/vendor/guzzlehttp/guzzle/CHANGELOG.md ADDED
@@ -0,0 +1,1203 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # CHANGELOG
2
+
3
+ ## 6.1.1 - 2015-11-22
4
+
5
+ * Bug fix: Proxy::wrapSync() now correctly proxies to the appropriate handler
6
+ https://github.com/guzzle/guzzle/commit/911bcbc8b434adce64e223a6d1d14e9a8f63e4e4
7
+ * Feature: HandlerStack is now more generic.
8
+ https://github.com/guzzle/guzzle/commit/f2102941331cda544745eedd97fc8fd46e1ee33e
9
+ * Bug fix: setting verify to false in the StreamHandler now disables peer
10
+ verification. https://github.com/guzzle/guzzle/issues/1256
11
+ * Feature: Middleware now uses an exception factory, including more error
12
+ context. https://github.com/guzzle/guzzle/pull/1282
13
+ * Feature: better support for disabled functions.
14
+ https://github.com/guzzle/guzzle/pull/1287
15
+ * Bug fix: fixed regression where MockHandler was not using `sink`.
16
+ https://github.com/guzzle/guzzle/pull/1292
17
+
18
+ ## 6.1.0 - 2015-09-08
19
+
20
+ * Feature: Added the `on_stats` request option to provide access to transfer
21
+ statistics for requests. https://github.com/guzzle/guzzle/pull/1202
22
+ * Feature: Added the ability to persist session cookies in CookieJars.
23
+ https://github.com/guzzle/guzzle/pull/1195
24
+ * Feature: Some compatibility updates for Google APP Engine
25
+ https://github.com/guzzle/guzzle/pull/1216
26
+ * Feature: Added support for NO_PROXY to prevent the use of a proxy based on
27
+ a simple set of rules. https://github.com/guzzle/guzzle/pull/1197
28
+ * Feature: Cookies can now contain square brackets.
29
+ https://github.com/guzzle/guzzle/pull/1237
30
+ * Bug fix: Now correctly parsing `=` inside of quotes in Cookies.
31
+ https://github.com/guzzle/guzzle/pull/1232
32
+ * Bug fix: Cusotm cURL options now correctly override curl options of the
33
+ same name. https://github.com/guzzle/guzzle/pull/1221
34
+ * Bug fix: Content-Type header is now added when using an explicitly provided
35
+ multipart body. https://github.com/guzzle/guzzle/pull/1218
36
+ * Bug fix: Now ignoring Set-Cookie headers that have no name.
37
+ * Bug fix: Reason phrase is no longer cast to an int in some cases in the
38
+ cURL handler. https://github.com/guzzle/guzzle/pull/1187
39
+ * Bug fix: Remove the Authorization header when redirecting if the Host
40
+ header changes. https://github.com/guzzle/guzzle/pull/1207
41
+ * Bug fix: Cookie path matching fixes
42
+ https://github.com/guzzle/guzzle/issues/1129
43
+ * Bug fix: Fixing the cURL `body_as_string` setting
44
+ https://github.com/guzzle/guzzle/pull/1201
45
+ * Bug fix: quotes are no longer stripped when parsing cookies.
46
+ https://github.com/guzzle/guzzle/issues/1172
47
+ * Bug fix: `form_params` and `query` now always uses the `&` separator.
48
+ https://github.com/guzzle/guzzle/pull/1163
49
+ * Bug fix: Adding a Content-Length to PHP stream wrapper requests if not set.
50
+ https://github.com/guzzle/guzzle/pull/1189
51
+
52
+ ## 6.0.2 - 2015-07-04
53
+
54
+ * Fixed a memory leak in the curl handlers in which references to callbacks
55
+ were not being removed by `curl_reset`.
56
+ * Cookies are now extracted properly before redirects.
57
+ * Cookies now allow more character ranges.
58
+ * Decoded Content-Encoding responses are now modified to correctly reflect
59
+ their state if the encoding was automatically removed by a handler. This
60
+ means that the `Content-Encoding` header may be removed an the
61
+ `Content-Length` modified to reflect the message size after removing the
62
+ encoding.
63
+ * Added a more explicit error message when trying to use `form_params` and
64
+ `multipart` in the same request.
65
+ * Several fixes for HHVM support.
66
+ * Functions are now conditionally required using an additional level of
67
+ indirection to help with global Composer installations.
68
+
69
+ ## 6.0.1 - 2015-05-27
70
+
71
+ * Fixed a bug with serializing the `query` request option where the `&`
72
+ separator was missing.
73
+ * Added a better error message for when `body` is provided as an array. Please
74
+ use `form_params` or `multipart` instead.
75
+ * Various doc fixes.
76
+
77
+ ## 6.0.0 - 2015-05-26
78
+
79
+ * See the UPGRADING.md document for more information.
80
+ * Added `multipart` and `form_params` request options.
81
+ * Added `synchronous` request option.
82
+ * Added the `on_headers` request option.
83
+ * Fixed `expect` handling.
84
+ * No longer adding default middlewares in the client ctor. These need to be
85
+ present on the provided handler in order to work.
86
+ * Requests are no longer initiated when sending async requests with the
87
+ CurlMultiHandler. This prevents unexpected recursion from requests completing
88
+ while ticking the cURL loop.
89
+ * Removed the semantics of setting `default` to `true`. This is no longer
90
+ required now that the cURL loop is not ticked for async requests.
91
+ * Added request and response logging middleware.
92
+ * No longer allowing self signed certificates when using the StreamHandler.
93
+ * Ensuring that `sink` is valid if saving to a file.
94
+ * Request exceptions now include a "handler context" which provides handler
95
+ specific contextual information.
96
+ * Added `GuzzleHttp\RequestOptions` to allow request options to be applied
97
+ using constants.
98
+ * `$maxHandles` has been removed from CurlMultiHandler.
99
+ * `MultipartPostBody` is now part of the `guzzlehttp/psr7` package.
100
+
101
+ ## 5.3.0 - 2015-05-19
102
+
103
+ * Mock now supports `save_to`
104
+ * Marked `AbstractRequestEvent::getTransaction()` as public.
105
+ * Fixed a bug in which multiple headers using different casing would overwrite
106
+ previous headers in the associative array.
107
+ * Added `Utils::getDefaultHandler()`
108
+ * Marked `GuzzleHttp\Client::getDefaultUserAgent` as deprecated.
109
+ * URL scheme is now always lowercased.
110
+
111
+ ## 6.0.0-beta.1
112
+
113
+ * Requires PHP >= 5.5
114
+ * Updated to use PSR-7
115
+ * Requires immutable messages, which basically means an event based system
116
+ owned by a request instance is no longer possible.
117
+ * Utilizing the [Guzzle PSR-7 package](https://github.com/guzzle/psr7).
118
+ * Removed the dependency on `guzzlehttp/streams`. These stream abstractions
119
+ are available in the `guzzlehttp/psr7` package under the `GuzzleHttp\Psr7`
120
+ namespace.
121
+ * Added middleware and handler system
122
+ * Replaced the Guzzle event and subscriber system with a middleware system.
123
+ * No longer depends on RingPHP, but rather places the HTTP handlers directly
124
+ in Guzzle, operating on PSR-7 messages.
125
+ * Retry logic is now encapsulated in `GuzzleHttp\Middleware::retry`, which
126
+ means the `guzzlehttp/retry-subscriber` is now obsolete.
127
+ * Mocking responses is now handled using `GuzzleHttp\Handler\MockHandler`.
128
+ * Asynchronous responses
129
+ * No longer supports the `future` request option to send an async request.
130
+ Instead, use one of the `*Async` methods of a client (e.g., `requestAsync`,
131
+ `getAsync`, etc.).
132
+ * Utilizing `GuzzleHttp\Promise` instead of React's promise library to avoid
133
+ recursion required by chaining and forwarding react promises. See
134
+ https://github.com/guzzle/promises
135
+ * Added `requestAsync` and `sendAsync` to send request asynchronously.
136
+ * Added magic methods for `getAsync()`, `postAsync()`, etc. to send requests
137
+ asynchronously.
138
+ * Request options
139
+ * POST and form updates
140
+ * Added the `form_fields` and `form_files` request options.
141
+ * Removed the `GuzzleHttp\Post` namespace.
142
+ * The `body` request option no longer accepts an array for POST requests.
143
+ * The `exceptions` request option has been deprecated in favor of the
144
+ `http_errors` request options.
145
+ * The `save_to` request option has been deprecated in favor of `sink` request
146
+ option.
147
+ * Clients no longer accept an array of URI template string and variables for
148
+ URI variables. You will need to expand URI templates before passing them
149
+ into a client constructor or request method.
150
+ * Client methods `get()`, `post()`, `put()`, `patch()`, `options()`, etc. are
151
+ now magic methods that will send synchronous requests.
152
+ * Replaced `Utils.php` with plain functions in `functions.php`.
153
+ * Removed `GuzzleHttp\Collection`.
154
+ * Removed `GuzzleHttp\BatchResults`. Batched pool results are now returned as
155
+ an array.
156
+ * Removed `GuzzleHttp\Query`. Query string handling is now handled using an
157
+ associative array passed into the `query` request option. The query string
158
+ is serialized using PHP's `http_build_query`. If you need more control, you
159
+ can pass the query string in as a string.
160
+ * `GuzzleHttp\QueryParser` has been replaced with the
161
+ `GuzzleHttp\Psr7\parse_query`.
162
+
163
+ ## 5.2.0 - 2015-01-27
164
+
165
+ * Added `AppliesHeadersInterface` to make applying headers to a request based
166
+ on the body more generic and not specific to `PostBodyInterface`.
167
+ * Reduced the number of stack frames needed to send requests.
168
+ * Nested futures are now resolved in the client rather than the RequestFsm
169
+ * Finishing state transitions is now handled in the RequestFsm rather than the
170
+ RingBridge.
171
+ * Added a guard in the Pool class to not use recursion for request retries.
172
+
173
+ ## 5.1.0 - 2014-12-19
174
+
175
+ * Pool class no longer uses recursion when a request is intercepted.
176
+ * The size of a Pool can now be dynamically adjusted using a callback.
177
+ See https://github.com/guzzle/guzzle/pull/943.
178
+ * Setting a request option to `null` when creating a request with a client will
179
+ ensure that the option is not set. This allows you to overwrite default
180
+ request options on a per-request basis.
181
+ See https://github.com/guzzle/guzzle/pull/937.
182
+ * Added the ability to limit which protocols are allowed for redirects by
183
+ specifying a `protocols` array in the `allow_redirects` request option.
184
+ * Nested futures due to retries are now resolved when waiting for synchronous
185
+ responses. See https://github.com/guzzle/guzzle/pull/947.
186
+ * `"0"` is now an allowed URI path. See
187
+ https://github.com/guzzle/guzzle/pull/935.
188
+ * `Query` no longer typehints on the `$query` argument in the constructor,
189
+ allowing for strings and arrays.
190
+ * Exceptions thrown in the `end` event are now correctly wrapped with Guzzle
191
+ specific exceptions if necessary.
192
+
193
+ ## 5.0.3 - 2014-11-03
194
+
195
+ This change updates query strings so that they are treated as un-encoded values
196
+ by default where the value represents an un-encoded value to send over the
197
+ wire. A Query object then encodes the value before sending over the wire. This
198
+ means that even value query string values (e.g., ":") are url encoded. This
199
+ makes the Query class match PHP's http_build_query function. However, if you
200
+ want to send requests over the wire using valid query string characters that do
201
+ not need to be encoded, then you can provide a string to Url::setQuery() and
202
+ pass true as the second argument to specify that the query string is a raw
203
+ string that should not be parsed or encoded (unless a call to getQuery() is
204
+ subsequently made, forcing the query-string to be converted into a Query
205
+ object).
206
+
207
+ ## 5.0.2 - 2014-10-30
208
+
209
+ * Added a trailing `\r\n` to multipart/form-data payloads. See
210
+ https://github.com/guzzle/guzzle/pull/871
211
+ * Added a `GuzzleHttp\Pool::send()` convenience method to match the docs.
212
+ * Status codes are now returned as integers. See
213
+ https://github.com/guzzle/guzzle/issues/881
214
+ * No longer overwriting an existing `application/x-www-form-urlencoded` header
215
+ when sending POST requests, allowing for customized headers. See
216
+ https://github.com/guzzle/guzzle/issues/877
217
+ * Improved path URL serialization.
218
+
219
+ * No longer double percent-encoding characters in the path or query string if
220
+ they are already encoded.
221
+ * Now properly encoding the supplied path to a URL object, instead of only
222
+ encoding ' ' and '?'.
223
+ * Note: This has been changed in 5.0.3 to now encode query string values by
224
+ default unless the `rawString` argument is provided when setting the query
225
+ string on a URL: Now allowing many more characters to be present in the
226
+ query string without being percent encoded. See http://tools.ietf.org/html/rfc3986#appendix-A
227
+
228
+ ## 5.0.1 - 2014-10-16
229
+
230
+ Bugfix release.
231
+
232
+ * Fixed an issue where connection errors still returned response object in
233
+ error and end events event though the response is unusable. This has been
234
+ corrected so that a response is not returned in the `getResponse` method of
235
+ these events if the response did not complete. https://github.com/guzzle/guzzle/issues/867
236
+ * Fixed an issue where transfer statistics were not being populated in the
237
+ RingBridge. https://github.com/guzzle/guzzle/issues/866
238
+
239
+ ## 5.0.0 - 2014-10-12
240
+
241
+ Adding support for non-blocking responses and some minor API cleanup.
242
+
243
+ ### New Features
244
+
245
+ * Added support for non-blocking responses based on `guzzlehttp/guzzle-ring`.
246
+ * Added a public API for creating a default HTTP adapter.
247
+ * Updated the redirect plugin to be non-blocking so that redirects are sent
248
+ concurrently. Other plugins like this can now be updated to be non-blocking.
249
+ * Added a "progress" event so that you can get upload and download progress
250
+ events.
251
+ * Added `GuzzleHttp\Pool` which implements FutureInterface and transfers
252
+ requests concurrently using a capped pool size as efficiently as possible.
253
+ * Added `hasListeners()` to EmitterInterface.
254
+ * Removed `GuzzleHttp\ClientInterface::sendAll` and marked
255
+ `GuzzleHttp\Client::sendAll` as deprecated (it's still there, just not the
256
+ recommended way).
257
+
258
+ ### Breaking changes
259
+
260
+ The breaking changes in this release are relatively minor. The biggest thing to
261
+ look out for is that request and response objects no longer implement fluent
262
+ interfaces.
263
+
264
+ * Removed the fluent interfaces (i.e., `return $this`) from requests,
265
+ responses, `GuzzleHttp\Collection`, `GuzzleHttp\Url`,
266
+ `GuzzleHttp\Query`, `GuzzleHttp\Post\PostBody`, and
267
+ `GuzzleHttp\Cookie\SetCookie`. This blog post provides a good outline of
268
+ why I did this: http://ocramius.github.io/blog/fluent-interfaces-are-evil/.
269
+ This also makes the Guzzle message interfaces compatible with the current
270
+ PSR-7 message proposal.
271
+ * Removed "functions.php", so that Guzzle is truly PSR-4 compliant. Except
272
+ for the HTTP request functions from function.php, these functions are now
273
+ implemented in `GuzzleHttp\Utils` using camelCase. `GuzzleHttp\json_decode`
274
+ moved to `GuzzleHttp\Utils::jsonDecode`. `GuzzleHttp\get_path` moved to
275
+ `GuzzleHttp\Utils::getPath`. `GuzzleHttp\set_path` moved to
276
+ `GuzzleHttp\Utils::setPath`. `GuzzleHttp\batch` should now be
277
+ `GuzzleHttp\Pool::batch`, which returns an `objectStorage`. Using functions.php
278
+ caused problems for many users: they aren't PSR-4 compliant, require an
279
+ explicit include, and needed an if-guard to ensure that the functions are not
280
+ declared multiple times.
281
+ * Rewrote adapter layer.
282
+ * Removing all classes from `GuzzleHttp\Adapter`, these are now
283
+ implemented as callables that are stored in `GuzzleHttp\Ring\Client`.
284
+ * Removed the concept of "parallel adapters". Sending requests serially or
285
+ concurrently is now handled using a single adapter.
286
+ * Moved `GuzzleHttp\Adapter\Transaction` to `GuzzleHttp\Transaction`. The
287
+ Transaction object now exposes the request, response, and client as public
288
+ properties. The getters and setters have been removed.
289
+ * Removed the "headers" event. This event was only useful for changing the
290
+ body a response once the headers of the response were known. You can implement
291
+ a similar behavior in a number of ways. One example might be to use a
292
+ FnStream that has access to the transaction being sent. For example, when the
293
+ first byte is written, you could check if the response headers match your
294
+ expectations, and if so, change the actual stream body that is being
295
+ written to.
296
+ * Removed the `asArray` parameter from
297
+ `GuzzleHttp\Message\MessageInterface::getHeader`. If you want to get a header
298
+ value as an array, then use the newly added `getHeaderAsArray()` method of
299
+ `MessageInterface`. This change makes the Guzzle interfaces compatible with
300
+ the PSR-7 interfaces.
301
+ * `GuzzleHttp\Message\MessageFactory` no longer allows subclasses to add
302
+ custom request options using double-dispatch (this was an implementation
303
+ detail). Instead, you should now provide an associative array to the
304
+ constructor which is a mapping of the request option name mapping to a
305
+ function that applies the option value to a request.
306
+ * Removed the concept of "throwImmediately" from exceptions and error events.
307
+ This control mechanism was used to stop a transfer of concurrent requests
308
+ from completing. This can now be handled by throwing the exception or by
309
+ cancelling a pool of requests or each outstanding future request individually.
310
+ * Updated to "GuzzleHttp\Streams" 3.0.
311
+ * `GuzzleHttp\Stream\StreamInterface::getContents()` no longer accepts a
312
+ `maxLen` parameter. This update makes the Guzzle streams project
313
+ compatible with the current PSR-7 proposal.
314
+ * `GuzzleHttp\Stream\Stream::__construct`,
315
+ `GuzzleHttp\Stream\Stream::factory`, and
316
+ `GuzzleHttp\Stream\Utils::create` no longer accept a size in the second
317
+ argument. They now accept an associative array of options, including the
318
+ "size" key and "metadata" key which can be used to provide custom metadata.
319
+
320
+ ## 4.2.2 - 2014-09-08
321
+
322
+ * Fixed a memory leak in the CurlAdapter when reusing cURL handles.
323
+ * No longer using `request_fulluri` in stream adapter proxies.
324
+ * Relative redirects are now based on the last response, not the first response.
325
+
326
+ ## 4.2.1 - 2014-08-19
327
+
328
+ * Ensuring that the StreamAdapter does not always add a Content-Type header
329
+ * Adding automated github releases with a phar and zip
330
+
331
+ ## 4.2.0 - 2014-08-17
332
+
333
+ * Now merging in default options using a case-insensitive comparison.
334
+ Closes https://github.com/guzzle/guzzle/issues/767
335
+ * Added the ability to automatically decode `Content-Encoding` response bodies
336
+ using the `decode_content` request option. This is set to `true` by default
337
+ to decode the response body if it comes over the wire with a
338
+ `Content-Encoding`. Set this value to `false` to disable decoding the
339
+ response content, and pass a string to provide a request `Accept-Encoding`
340
+ header and turn on automatic response decoding. This feature now allows you
341
+ to pass an `Accept-Encoding` header in the headers of a request but still
342
+ disable automatic response decoding.
343
+ Closes https://github.com/guzzle/guzzle/issues/764
344
+ * Added the ability to throw an exception immediately when transferring
345
+ requests in parallel. Closes https://github.com/guzzle/guzzle/issues/760
346
+ * Updating guzzlehttp/streams dependency to ~2.1
347
+ * No longer utilizing the now deprecated namespaced methods from the stream
348
+ package.
349
+
350
+ ## 4.1.8 - 2014-08-14
351
+
352
+ * Fixed an issue in the CurlFactory that caused setting the `stream=false`
353
+ request option to throw an exception.
354
+ See: https://github.com/guzzle/guzzle/issues/769
355
+ * TransactionIterator now calls rewind on the inner iterator.
356
+ See: https://github.com/guzzle/guzzle/pull/765
357
+ * You can now set the `Content-Type` header to `multipart/form-data`
358
+ when creating POST requests to force multipart bodies.
359
+ See https://github.com/guzzle/guzzle/issues/768
360
+
361
+ ## 4.1.7 - 2014-08-07
362
+
363
+ * Fixed an error in the HistoryPlugin that caused the same request and response
364
+ to be logged multiple times when an HTTP protocol error occurs.
365
+ * Ensuring that cURL does not add a default Content-Type when no Content-Type
366
+ has been supplied by the user. This prevents the adapter layer from modifying
367
+ the request that is sent over the wire after any listeners may have already
368
+ put the request in a desired state (e.g., signed the request).
369
+ * Throwing an exception when you attempt to send requests that have the
370
+ "stream" set to true in parallel using the MultiAdapter.
371
+ * Only calling curl_multi_select when there are active cURL handles. This was
372
+ previously changed and caused performance problems on some systems due to PHP
373
+ always selecting until the maximum select timeout.
374
+ * Fixed a bug where multipart/form-data POST fields were not correctly
375
+ aggregated (e.g., values with "&").
376
+
377
+ ## 4.1.6 - 2014-08-03
378
+
379
+ * Added helper methods to make it easier to represent messages as strings,
380
+ including getting the start line and getting headers as a string.
381
+
382
+ ## 4.1.5 - 2014-08-02
383
+
384
+ * Automatically retrying cURL "Connection died, retrying a fresh connect"
385
+ errors when possible.
386
+ * cURL implementation cleanup
387
+ * Allowing multiple event subscriber listeners to be registered per event by
388
+ passing an array of arrays of listener configuration.
389
+
390
+ ## 4.1.4 - 2014-07-22
391
+
392
+ * Fixed a bug that caused multi-part POST requests with more than one field to
393
+ serialize incorrectly.
394
+ * Paths can now be set to "0"
395
+ * `ResponseInterface::xml` now accepts a `libxml_options` option and added a
396
+ missing default argument that was required when parsing XML response bodies.
397
+ * A `save_to` stream is now created lazily, which means that files are not
398
+ created on disk unless a request succeeds.
399
+
400
+ ## 4.1.3 - 2014-07-15
401
+
402
+ * Various fixes to multipart/form-data POST uploads
403
+ * Wrapping function.php in an if-statement to ensure Guzzle can be used
404
+ globally and in a Composer install
405
+ * Fixed an issue with generating and merging in events to an event array
406
+ * POST headers are only applied before sending a request to allow you to change
407
+ the query aggregator used before uploading
408
+ * Added much more robust query string parsing
409
+ * Fixed various parsing and normalization issues with URLs
410
+ * Fixing an issue where multi-valued headers were not being utilized correctly
411
+ in the StreamAdapter
412
+
413
+ ## 4.1.2 - 2014-06-18
414
+
415
+ * Added support for sending payloads with GET requests
416
+
417
+ ## 4.1.1 - 2014-06-08
418
+
419
+ * Fixed an issue related to using custom message factory options in subclasses
420
+ * Fixed an issue with nested form fields in a multi-part POST
421
+ * Fixed an issue with using the `json` request option for POST requests
422
+ * Added `ToArrayInterface` to `GuzzleHttp\Cookie\CookieJar`
423
+
424
+ ## 4.1.0 - 2014-05-27
425
+
426
+ * Added a `json` request option to easily serialize JSON payloads.
427
+ * Added a `GuzzleHttp\json_decode()` wrapper to safely parse JSON.
428
+ * Added `setPort()` and `getPort()` to `GuzzleHttp\Message\RequestInterface`.
429
+ * Added the ability to provide an emitter to a client in the client constructor.
430
+ * Added the ability to persist a cookie session using $_SESSION.
431
+ * Added a trait that can be used to add event listeners to an iterator.
432
+ * Removed request method constants from RequestInterface.
433
+ * Fixed warning when invalid request start-lines are received.
434
+ * Updated MessageFactory to work with custom request option methods.
435
+ * Updated cacert bundle to latest build.
436
+
437
+ 4.0.2 (2014-04-16)
438
+ ------------------
439
+
440
+ * Proxy requests using the StreamAdapter now properly use request_fulluri (#632)
441
+ * Added the ability to set scalars as POST fields (#628)
442
+
443
+ ## 4.0.1 - 2014-04-04
444
+
445
+ * The HTTP status code of a response is now set as the exception code of
446
+ RequestException objects.
447
+ * 303 redirects will now correctly switch from POST to GET requests.
448
+ * The default parallel adapter of a client now correctly uses the MultiAdapter.
449
+ * HasDataTrait now initializes the internal data array as an empty array so
450
+ that the toArray() method always returns an array.
451
+
452
+ ## 4.0.0 - 2014-03-29
453
+
454
+ * For more information on the 4.0 transition, see:
455
+ http://mtdowling.com/blog/2014/03/15/guzzle-4-rc/
456
+ * For information on changes and upgrading, see:
457
+ https://github.com/guzzle/guzzle/blob/master/UPGRADING.md#3x-to-40
458
+ * Added `GuzzleHttp\batch()` as a convenience function for sending requests in
459
+ parallel without needing to write asynchronous code.
460
+ * Restructured how events are added to `GuzzleHttp\ClientInterface::sendAll()`.
461
+ You can now pass a callable or an array of associative arrays where each
462
+ associative array contains the "fn", "priority", and "once" keys.
463
+
464
+ ## 4.0.0.rc-2 - 2014-03-25
465
+
466
+ * Removed `getConfig()` and `setConfig()` from clients to avoid confusion
467
+ around whether things like base_url, message_factory, etc. should be able to
468
+ be retrieved or modified.
469
+ * Added `getDefaultOption()` and `setDefaultOption()` to ClientInterface
470
+ * functions.php functions were renamed using snake_case to match PHP idioms
471
+ * Added support for `HTTP_PROXY`, `HTTPS_PROXY`, and
472
+ `GUZZLE_CURL_SELECT_TIMEOUT` environment variables
473
+ * Added the ability to specify custom `sendAll()` event priorities
474
+ * Added the ability to specify custom stream context options to the stream
475
+ adapter.
476
+ * Added a functions.php function for `get_path()` and `set_path()`
477
+ * CurlAdapter and MultiAdapter now use a callable to generate curl resources
478
+ * MockAdapter now properly reads a body and emits a `headers` event
479
+ * Updated Url class to check if a scheme and host are set before adding ":"
480
+ and "//". This allows empty Url (e.g., "") to be serialized as "".
481
+ * Parsing invalid XML no longer emits warnings
482
+ * Curl classes now properly throw AdapterExceptions
483
+ * Various performance optimizations
484
+ * Streams are created with the faster `Stream\create()` function
485
+ * Marked deprecation_proxy() as internal
486
+ * Test server is now a collection of static methods on a class
487
+
488
+ ## 4.0.0-rc.1 - 2014-03-15
489
+
490
+ * See https://github.com/guzzle/guzzle/blob/master/UPGRADING.md#3x-to-40
491
+
492
+ ## 3.8.1 - 2014-01-28
493
+
494
+ * Bug: Always using GET requests when redirecting from a 303 response
495
+ * Bug: CURLOPT_SSL_VERIFYHOST is now correctly set to false when setting `$certificateAuthority` to false in
496
+ `Guzzle\Http\ClientInterface::setSslVerification()`
497
+ * Bug: RedirectPlugin now uses strict RFC 3986 compliance when combining a base URL with a relative URL
498
+ * Bug: The body of a request can now be set to `"0"`
499
+ * Sending PHP stream requests no longer forces `HTTP/1.0`
500
+ * Adding more information to ExceptionCollection exceptions so that users have more context, including a stack trace of
501
+ each sub-exception
502
+ * Updated the `$ref` attribute in service descriptions to merge over any existing parameters of a schema (rather than
503
+ clobbering everything).
504
+ * Merging URLs will now use the query string object from the relative URL (thus allowing custom query aggregators)
505
+ * Query strings are now parsed in a way that they do no convert empty keys with no value to have a dangling `=`.
506
+ For example `foo&bar=baz` is now correctly parsed and recognized as `foo&bar=baz` rather than `foo=&bar=baz`.
507
+ * Now properly escaping the regular expression delimiter when matching Cookie domains.
508
+ * Network access is now disabled when loading XML documents
509
+
510
+ ## 3.8.0 - 2013-12-05
511
+
512
+ * Added the ability to define a POST name for a file
513
+ * JSON response parsing now properly walks additionalProperties
514
+ * cURL error code 18 is now retried automatically in the BackoffPlugin
515
+ * Fixed a cURL error when URLs contain fragments
516
+ * Fixed an issue in the BackoffPlugin retry event where it was trying to access all exceptions as if they were
517
+ CurlExceptions
518
+ * CURLOPT_PROGRESS function fix for PHP 5.5 (69fcc1e)
519
+ * Added the ability for Guzzle to work with older versions of cURL that do not support `CURLOPT_TIMEOUT_MS`
520
+ * Fixed a bug that was encountered when parsing empty header parameters
521
+ * UriTemplate now has a `setRegex()` method to match the docs
522
+ * The `debug` request parameter now checks if it is truthy rather than if it exists
523
+ * Setting the `debug` request parameter to true shows verbose cURL output instead of using the LogPlugin
524
+ * Added the ability to combine URLs using strict RFC 3986 compliance
525
+ * Command objects can now return the validation errors encountered by the command
526
+ * Various fixes to cache revalidation (#437 and 29797e5)
527
+ * Various fixes to the AsyncPlugin
528
+ * Cleaned up build scripts
529
+
530
+ ## 3.7.4 - 2013-10-02
531
+
532
+ * Bug fix: 0 is now an allowed value in a description parameter that has a default value (#430)
533
+ * Bug fix: SchemaFormatter now returns an integer when formatting to a Unix timestamp
534
+ (see https://github.com/aws/aws-sdk-php/issues/147)
535
+ * Bug fix: Cleaned up and fixed URL dot segment removal to properly resolve internal dots
536
+ * Minimum PHP version is now properly specified as 5.3.3 (up from 5.3.2) (#420)
537
+ * Updated the bundled cacert.pem (#419)
538
+ * OauthPlugin now supports adding authentication to headers or query string (#425)
539
+
540
+ ## 3.7.3 - 2013-09-08
541
+
542
+ * Added the ability to get the exception associated with a request/command when using `MultiTransferException` and
543
+ `CommandTransferException`.
544
+ * Setting `additionalParameters` of a response to false is now honored when parsing responses with a service description
545
+ * Schemas are only injected into response models when explicitly configured.
546
+ * No longer guessing Content-Type based on the path of a request. Content-Type is now only guessed based on the path of
547
+ an EntityBody.
548
+ * Bug fix: ChunkedIterator can now properly chunk a \Traversable as well as an \Iterator.
549
+ * Bug fix: FilterIterator now relies on `\Iterator` instead of `\Traversable`.
550
+ * Bug fix: Gracefully handling malformed responses in RequestMediator::writeResponseBody()
551
+ * Bug fix: Replaced call to canCache with canCacheRequest in the CallbackCanCacheStrategy of the CachePlugin
552
+ * Bug fix: Visiting XML attributes first before visiting XML children when serializing requests
553
+ * Bug fix: Properly parsing headers that contain commas contained in quotes
554
+ * Bug fix: mimetype guessing based on a filename is now case-insensitive
555
+
556
+ ## 3.7.2 - 2013-08-02
557
+
558
+ * Bug fix: Properly URL encoding paths when using the PHP-only version of the UriTemplate expander
559
+ See https://github.com/guzzle/guzzle/issues/371
560
+ * Bug fix: Cookie domains are now matched correctly according to RFC 6265
561
+ See https://github.com/guzzle/guzzle/issues/377
562
+ * Bug fix: GET parameters are now used when calculating an OAuth signature
563
+ * Bug fix: Fixed an issue with cache revalidation where the If-None-Match header was being double quoted
564
+ * `Guzzle\Common\AbstractHasDispatcher::dispatch()` now returns the event that was dispatched
565
+ * `Guzzle\Http\QueryString::factory()` now guesses the most appropriate query aggregator to used based on the input.
566
+ See https://github.com/guzzle/guzzle/issues/379
567
+ * Added a way to add custom domain objects to service description parsing using the `operation.parse_class` event. See
568
+ https://github.com/guzzle/guzzle/pull/380
569
+ * cURL multi cleanup and optimizations
570
+
571
+ ## 3.7.1 - 2013-07-05
572
+
573
+ * Bug fix: Setting default options on a client now works
574
+ * Bug fix: Setting options on HEAD requests now works. See #352
575
+ * Bug fix: Moving stream factory before send event to before building the stream. See #353
576
+ * Bug fix: Cookies no longer match on IP addresses per RFC 6265
577
+ * Bug fix: Correctly parsing header parameters that are in `<>` and quotes
578
+ * Added `cert` and `ssl_key` as request options
579
+ * `Host` header can now diverge from the host part of a URL if the header is set manually
580
+ * `Guzzle\Service\Command\LocationVisitor\Request\XmlVisitor` was rewritten to change from using SimpleXML to XMLWriter
581
+ * OAuth parameters are only added via the plugin if they aren't already set
582
+ * Exceptions are now thrown when a URL cannot be parsed
583
+ * Returning `false` if `Guzzle\Http\EntityBody::getContentMd5()` fails
584
+ * Not setting a `Content-MD5` on a command if calculating the Content-MD5 fails via the CommandContentMd5Plugin
585
+
586
+ ## 3.7.0 - 2013-06-10
587
+
588
+ * See UPGRADING.md for more information on how to upgrade.
589
+ * Requests now support the ability to specify an array of $options when creating a request to more easily modify a
590
+ request. You can pass a 'request.options' configuration setting to a client to apply default request options to
591
+ every request created by a client (e.g. default query string variables, headers, curl options, etc.).
592
+ * Added a static facade class that allows you to use Guzzle with static methods and mount the class to `\Guzzle`.
593
+ See `Guzzle\Http\StaticClient::mount`.
594
+ * Added `command.request_options` to `Guzzle\Service\Command\AbstractCommand` to pass request options to requests
595
+ created by a command (e.g. custom headers, query string variables, timeout settings, etc.).
596
+ * Stream size in `Guzzle\Stream\PhpStreamRequestFactory` will now be set if Content-Length is returned in the
597
+ headers of a response
598
+ * Added `Guzzle\Common\Collection::setPath($path, $value)` to set a value into an array using a nested key
599
+ (e.g. `$collection->setPath('foo/baz/bar', 'test'); echo $collection['foo']['bar']['bar'];`)
600
+ * ServiceBuilders now support storing and retrieving arbitrary data
601
+ * CachePlugin can now purge all resources for a given URI
602
+ * CachePlugin can automatically purge matching cached items when a non-idempotent request is sent to a resource
603
+ * CachePlugin now uses the Vary header to determine if a resource is a cache hit
604
+ * `Guzzle\Http\Message\Response` now implements `\Serializable`
605
+ * Added `Guzzle\Cache\CacheAdapterFactory::fromCache()` to more easily create cache adapters
606
+ * `Guzzle\Service\ClientInterface::execute()` now accepts an array, single command, or Traversable
607
+ * Fixed a bug in `Guzzle\Http\Message\Header\Link::addLink()`
608
+ * Better handling of calculating the size of a stream in `Guzzle\Stream\Stream` using fstat() and caching the size
609
+ * `Guzzle\Common\Exception\ExceptionCollection` now creates a more readable exception message
610
+ * Fixing BC break: Added back the MonologLogAdapter implementation rather than extending from PsrLog so that older
611
+ Symfony users can still use the old version of Monolog.
612
+ * Fixing BC break: Added the implementation back in for `Guzzle\Http\Message\AbstractMessage::getTokenizedHeader()`.
613
+ Now triggering an E_USER_DEPRECATED warning when used. Use `$message->getHeader()->parseParams()`.
614
+ * Several performance improvements to `Guzzle\Common\Collection`
615
+ * Added an `$options` argument to the end of the following methods of `Guzzle\Http\ClientInterface`:
616
+ createRequest, head, delete, put, patch, post, options, prepareRequest
617
+ * Added an `$options` argument to the end of `Guzzle\Http\Message\Request\RequestFactoryInterface::createRequest()`
618
+ * Added an `applyOptions()` method to `Guzzle\Http\Message\Request\RequestFactoryInterface`
619
+ * Changed `Guzzle\Http\ClientInterface::get($uri = null, $headers = null, $body = null)` to
620
+ `Guzzle\Http\ClientInterface::get($uri = null, $headers = null, $options = array())`. You can still pass in a
621
+ resource, string, or EntityBody into the $options parameter to specify the download location of the response.
622
+ * Changed `Guzzle\Common\Collection::__construct($data)` to no longer accepts a null value for `$data` but a
623
+ default `array()`
624
+ * Added `Guzzle\Stream\StreamInterface::isRepeatable`
625
+ * Removed `Guzzle\Http\ClientInterface::setDefaultHeaders(). Use
626
+ $client->getConfig()->setPath('request.options/headers/{header_name}', 'value')`. or
627
+ $client->getConfig()->setPath('request.options/headers', array('header_name' => 'value'))`.
628
+ * Removed `Guzzle\Http\ClientInterface::getDefaultHeaders(). Use $client->getConfig()->getPath('request.options/headers')`.
629
+ * Removed `Guzzle\Http\ClientInterface::expandTemplate()`
630
+ * Removed `Guzzle\Http\ClientInterface::setRequestFactory()`
631
+ * Removed `Guzzle\Http\ClientInterface::getCurlMulti()`
632
+ * Removed `Guzzle\Http\Message\RequestInterface::canCache`
633
+ * Removed `Guzzle\Http\Message\RequestInterface::setIsRedirect`
634
+ * Removed `Guzzle\Http\Message\RequestInterface::isRedirect`
635
+ * Made `Guzzle\Http\Client::expandTemplate` and `getUriTemplate` protected methods.
636
+ * You can now enable E_USER_DEPRECATED warnings to see if you are using a deprecated method by setting
637
+ `Guzzle\Common\Version::$emitWarnings` to true.
638
+ * Marked `Guzzle\Http\Message\Request::isResponseBodyRepeatable()` as deprecated. Use
639
+ `$request->getResponseBody()->isRepeatable()` instead.
640
+ * Marked `Guzzle\Http\Message\Request::canCache()` as deprecated. Use
641
+ `Guzzle\Plugin\Cache\DefaultCanCacheStrategy->canCacheRequest()` instead.
642
+ * Marked `Guzzle\Http\Message\Request::canCache()` as deprecated. Use
643
+ `Guzzle\Plugin\Cache\DefaultCanCacheStrategy->canCacheRequest()` instead.
644
+ * Marked `Guzzle\Http\Message\Request::setIsRedirect()` as deprecated. Use the HistoryPlugin instead.
645
+ * Marked `Guzzle\Http\Message\Request::isRedirect()` as deprecated. Use the HistoryPlugin instead.
646
+ * Marked `Guzzle\Cache\CacheAdapterFactory::factory()` as deprecated
647
+ * Marked 'command.headers', 'command.response_body' and 'command.on_complete' as deprecated for AbstractCommand.
648
+ These will work through Guzzle 4.0
649
+ * Marked 'request.params' for `Guzzle\Http\Client` as deprecated. Use [request.options][params].
650
+ * Marked `Guzzle\Service\Client::enableMagicMethods()` as deprecated. Magic methods can no longer be disabled on a Guzzle\Service\Client.
651
+ * Marked `Guzzle\Service\Client::getDefaultHeaders()` as deprecated. Use $client->getConfig()->getPath('request.options/headers')`.
652
+ * Marked `Guzzle\Service\Client::setDefaultHeaders()` as deprecated. Use $client->getConfig()->setPath('request.options/headers/{header_name}', 'value')`.
653
+ * Marked `Guzzle\Parser\Url\UrlParser` as deprecated. Just use PHP's `parse_url()` and percent encode your UTF-8.
654
+ * Marked `Guzzle\Common\Collection::inject()` as deprecated.
655
+ * Marked `Guzzle\Plugin\CurlAuth\CurlAuthPlugin` as deprecated. Use `$client->getConfig()->setPath('request.options/auth', array('user', 'pass', 'Basic|Digest');`
656
+ * CacheKeyProviderInterface and DefaultCacheKeyProvider are no longer used. All of this logic is handled in a
657
+ CacheStorageInterface. These two objects and interface will be removed in a future version.
658
+ * Always setting X-cache headers on cached responses
659
+ * Default cache TTLs are now handled by the CacheStorageInterface of a CachePlugin
660
+ * `CacheStorageInterface::cache($key, Response $response, $ttl = null)` has changed to `cache(RequestInterface
661
+ $request, Response $response);`
662
+ * `CacheStorageInterface::fetch($key)` has changed to `fetch(RequestInterface $request);`
663
+ * `CacheStorageInterface::delete($key)` has changed to `delete(RequestInterface $request);`
664
+ * Added `CacheStorageInterface::purge($url)`
665
+ * `DefaultRevalidation::__construct(CacheKeyProviderInterface $cacheKey, CacheStorageInterface $cache, CachePlugin
666
+ $plugin)` has changed to `DefaultRevalidation::__construct(CacheStorageInterface $cache,
667
+ CanCacheStrategyInterface $canCache = null)`
668
+ * Added `RevalidationInterface::shouldRevalidate(RequestInterface $request, Response $response)`
669
+
670
+ ## 3.6.0 - 2013-05-29
671
+
672
+ * ServiceDescription now implements ToArrayInterface
673
+ * Added command.hidden_params to blacklist certain headers from being treated as additionalParameters
674
+ * Guzzle can now correctly parse incomplete URLs
675
+ * Mixed casing of headers are now forced to be a single consistent casing across all values for that header.
676
+ * Messages internally use a HeaderCollection object to delegate handling case-insensitive header resolution
677
+ * Removed the whole changedHeader() function system of messages because all header changes now go through addHeader().
678
+ * Specific header implementations can be created for complex headers. When a message creates a header, it uses a
679
+ HeaderFactory which can map specific headers to specific header classes. There is now a Link header and
680
+ CacheControl header implementation.
681
+ * Removed from interface: Guzzle\Http\ClientInterface::setUriTemplate
682
+ * Removed from interface: Guzzle\Http\ClientInterface::setCurlMulti()
683
+ * Removed Guzzle\Http\Message\Request::receivedRequestHeader() and implemented this functionality in
684
+ Guzzle\Http\Curl\RequestMediator
685
+ * Removed the optional $asString parameter from MessageInterface::getHeader(). Just cast the header to a string.
686
+ * Removed the optional $tryChunkedTransfer option from Guzzle\Http\Message\EntityEnclosingRequestInterface
687
+ * Removed the $asObjects argument from Guzzle\Http\Message\MessageInterface::getHeaders()
688
+ * Removed Guzzle\Parser\ParserRegister::get(). Use getParser()
689
+ * Removed Guzzle\Parser\ParserRegister::set(). Use registerParser().
690
+ * All response header helper functions return a string rather than mixing Header objects and strings inconsistently
691
+ * Removed cURL blacklist support. This is no longer necessary now that Expect, Accept, etc. are managed by Guzzle
692
+ directly via interfaces
693
+ * Removed the injecting of a request object onto a response object. The methods to get and set a request still exist
694
+ but are a no-op until removed.
695
+ * Most classes that used to require a `Guzzle\Service\Command\CommandInterface` typehint now request a
696
+ `Guzzle\Service\Command\ArrayCommandInterface`.
697
+ * Added `Guzzle\Http\Message\RequestInterface::startResponse()` to the RequestInterface to handle injecting a response
698
+ on a request while the request is still being transferred
699
+ * The ability to case-insensitively search for header values
700
+ * Guzzle\Http\Message\Header::hasExactHeader
701
+ * Guzzle\Http\Message\Header::raw. Use getAll()
702
+ * Deprecated cache control specific methods on Guzzle\Http\Message\AbstractMessage. Use the CacheControl header object
703
+ instead.
704
+ * `Guzzle\Service\Command\CommandInterface` now extends from ToArrayInterface and ArrayAccess
705
+ * Added the ability to cast Model objects to a string to view debug information.
706
+
707
+ ## 3.5.0 - 2013-05-13
708
+
709
+ * Bug: Fixed a regression so that request responses are parsed only once per oncomplete event rather than multiple times
710
+ * Bug: Better cleanup of one-time events across the board (when an event is meant to fire once, it will now remove
711
+ itself from the EventDispatcher)
712
+ * Bug: `Guzzle\Log\MessageFormatter` now properly writes "total_time" and "connect_time" values
713
+ * Bug: Cloning an EntityEnclosingRequest now clones the EntityBody too
714
+ * Bug: Fixed an undefined index error when parsing nested JSON responses with a sentAs parameter that reference a
715
+ non-existent key
716
+ * Bug: All __call() method arguments are now required (helps with mocking frameworks)
717
+ * Deprecating Response::getRequest() and now using a shallow clone of a request object to remove a circular reference
718
+ to help with refcount based garbage collection of resources created by sending a request
719
+ * Deprecating ZF1 cache and log adapters. These will be removed in the next major version.
720
+ * Deprecating `Response::getPreviousResponse()` (method signature still exists, but it'sdeprecated). Use the
721
+ HistoryPlugin for a history.
722
+ * Added a `responseBody` alias for the `response_body` location
723
+ * Refactored internals to no longer rely on Response::getRequest()
724
+ * HistoryPlugin can now be cast to a string
725
+ * HistoryPlugin now logs transactions rather than requests and responses to more accurately keep track of the requests
726
+ and responses that are sent over the wire
727
+ * Added `getEffectiveUrl()` and `getRedirectCount()` to Response objects
728
+
729
+ ## 3.4.3 - 2013-04-30
730
+
731
+ * Bug fix: Fixing bug introduced in 3.4.2 where redirect responses are duplicated on the final redirected response
732
+ * Added a check to re-extract the temp cacert bundle from the phar before sending each request
733
+
734
+ ## 3.4.2 - 2013-04-29
735
+
736
+ * Bug fix: Stream objects now work correctly with "a" and "a+" modes
737
+ * Bug fix: Removing `Transfer-Encoding: chunked` header when a Content-Length is present
738
+ * Bug fix: AsyncPlugin no longer forces HEAD requests
739
+ * Bug fix: DateTime timezones are now properly handled when using the service description schema formatter
740
+ * Bug fix: CachePlugin now properly handles stale-if-error directives when a request to the origin server fails
741
+ * Setting a response on a request will write to the custom request body from the response body if one is specified
742
+ * LogPlugin now writes to php://output when STDERR is undefined
743
+ * Added the ability to set multiple POST files for the same key in a single call
744
+ * application/x-www-form-urlencoded POSTs now use the utf-8 charset by default
745
+ * Added the ability to queue CurlExceptions to the MockPlugin
746
+ * Cleaned up how manual responses are queued on requests (removed "queued_response" and now using request.before_send)
747
+ * Configuration loading now allows remote files
748
+
749
+ ## 3.4.1 - 2013-04-16
750
+
751
+ * Large refactoring to how CurlMulti handles work. There is now a proxy that sits in front of a pool of CurlMulti
752
+ handles. This greatly simplifies the implementation, fixes a couple bugs, and provides a small performance boost.
753
+ * Exceptions are now properly grouped when sending requests in parallel
754
+ * Redirects are now properly aggregated when a multi transaction fails
755
+ * Redirects now set the response on the original object even in the event of a failure
756
+ * Bug fix: Model names are now properly set even when using $refs
757
+ * Added support for PHP 5.5's CurlFile to prevent warnings with the deprecated @ syntax
758
+ * Added support for oauth_callback in OAuth signatures
759
+ * Added support for oauth_verifier in OAuth signatures
760
+ * Added support to attempt to retrieve a command first literally, then ucfirst, the with inflection
761
+
762
+ ## 3.4.0 - 2013-04-11
763
+
764
+ * Bug fix: URLs are now resolved correctly based on http://tools.ietf.org/html/rfc3986#section-5.2. #289
765
+ * Bug fix: Absolute URLs with a path in a service description will now properly override the base URL. #289
766
+ * Bug fix: Parsing a query string with a single PHP array value will now result in an array. #263
767
+ * Bug fix: Better normalization of the User-Agent header to prevent duplicate headers. #264.
768
+ * Bug fix: Added `number` type to service descriptions.
769
+ * Bug fix: empty parameters are removed from an OAuth signature
770
+ * Bug fix: Revalidating a cache entry prefers the Last-Modified over the Date header
771
+ * Bug fix: Fixed "array to string" error when validating a union of types in a service description
772
+ * Bug fix: Removed code that attempted to determine the size of a stream when data is written to the stream
773
+ * Bug fix: Not including an `oauth_token` if the value is null in the OauthPlugin.
774
+ * Bug fix: Now correctly aggregating successful requests and failed requests in CurlMulti when a redirect occurs.
775
+ * The new default CURLOPT_TIMEOUT setting has been increased to 150 seconds so that Guzzle works on poor connections.
776
+ * Added a feature to EntityEnclosingRequest::setBody() that will automatically set the Content-Type of the request if
777
+ the Content-Type can be determined based on the entity body or the path of the request.
778
+ * Added the ability to overwrite configuration settings in a client when grabbing a throwaway client from a builder.
779
+ * Added support for a PSR-3 LogAdapter.
780
+ * Added a `command.after_prepare` event
781
+ * Added `oauth_callback` parameter to the OauthPlugin
782
+ * Added the ability to create a custom stream class when using a stream factory
783
+ * Added a CachingEntityBody decorator
784
+ * Added support for `additionalParameters` in service descriptions to define how custom parameters are serialized.
785
+ * The bundled SSL certificate is now provided in the phar file and extracted when running Guzzle from a phar.
786
+ * You can now send any EntityEnclosingRequest with POST fields or POST files and cURL will handle creating bodies
787
+ * POST requests using a custom entity body are now treated exactly like PUT requests but with a custom cURL method. This
788
+ means that the redirect behavior of POST requests with custom bodies will not be the same as POST requests that use
789
+ POST fields or files (the latter is only used when emulating a form POST in the browser).
790
+ * Lots of cleanup to CurlHandle::factory and RequestFactory::createRequest
791
+
792
+ ## 3.3.1 - 2013-03-10
793
+
794
+ * Added the ability to create PHP streaming responses from HTTP requests
795
+ * Bug fix: Running any filters when parsing response headers with service descriptions
796
+ * Bug fix: OauthPlugin fixes to allow for multi-dimensional array signing, and sorting parameters before signing
797
+ * Bug fix: Removed the adding of default empty arrays and false Booleans to responses in order to be consistent across
798
+ response location visitors.
799
+ * Bug fix: Removed the possibility of creating configuration files with circular dependencies
800
+ * RequestFactory::create() now uses the key of a POST file when setting the POST file name
801
+ * Added xmlAllowEmpty to serialize an XML body even if no XML specific parameters are set
802
+
803
+ ## 3.3.0 - 2013-03-03
804
+
805
+ * A large number of performance optimizations have been made
806
+ * Bug fix: Added 'wb' as a valid write mode for streams
807
+ * Bug fix: `Guzzle\Http\Message\Response::json()` now allows scalar values to be returned
808
+ * Bug fix: Fixed bug in `Guzzle\Http\Message\Response` where wrapping quotes were stripped from `getEtag()`
809
+ * BC: Removed `Guzzle\Http\Utils` class
810
+ * BC: Setting a service description on a client will no longer modify the client's command factories.
811
+ * BC: Emitting IO events from a RequestMediator is now a parameter that must be set in a request's curl options using
812
+ the 'emit_io' key. This was previously set under a request's parameters using 'curl.emit_io'
813
+ * BC: `Guzzle\Stream\Stream::getWrapper()` and `Guzzle\Stream\Stream::getSteamType()` are no longer converted to
814
+ lowercase
815
+ * Operation parameter objects are now lazy loaded internally
816
+ * Added ErrorResponsePlugin that can throw errors for responses defined in service description operations' errorResponses
817
+ * Added support for instantiating responseType=class responseClass classes. Classes must implement
818
+ `Guzzle\Service\Command\ResponseClassInterface`
819
+ * Added support for additionalProperties for top-level parameters in responseType=model responseClasses. These
820
+ additional properties also support locations and can be used to parse JSON responses where the outermost part of the
821
+ JSON is an array
822
+ * Added support for nested renaming of JSON models (rename sentAs to name)
823
+ * CachePlugin
824
+ * Added support for stale-if-error so that the CachePlugin can now serve stale content from the cache on error
825
+ * Debug headers can now added to cached response in the CachePlugin
826
+
827
+ ## 3.2.0 - 2013-02-14
828
+
829
+ * CurlMulti is no longer reused globally. A new multi object is created per-client. This helps to isolate clients.
830
+ * URLs with no path no longer contain a "/" by default
831
+ * Guzzle\Http\QueryString does no longer manages the leading "?". This is now handled in Guzzle\Http\Url.
832
+ * BadResponseException no longer includes the full request and response message
833
+ * Adding setData() to Guzzle\Service\Description\ServiceDescriptionInterface
834
+ * Adding getResponseBody() to Guzzle\Http\Message\RequestInterface
835
+ * Various updates to classes to use ServiceDescriptionInterface type hints rather than ServiceDescription
836
+ * Header values can now be normalized into distinct values when multiple headers are combined with a comma separated list
837
+ * xmlEncoding can now be customized for the XML declaration of a XML service description operation
838
+ * Guzzle\Http\QueryString now uses Guzzle\Http\QueryAggregator\QueryAggregatorInterface objects to add custom value
839
+ aggregation and no longer uses callbacks
840
+ * The URL encoding implementation of Guzzle\Http\QueryString can now be customized
841
+ * Bug fix: Filters were not always invoked for array service description parameters
842
+ * Bug fix: Redirects now use a target response body rather than a temporary response body
843
+ * Bug fix: The default exponential backoff BackoffPlugin was not giving when the request threshold was exceeded
844
+ * Bug fix: Guzzle now takes the first found value when grabbing Cache-Control directives
845
+
846
+ ## 3.1.2 - 2013-01-27
847
+
848
+ * Refactored how operation responses are parsed. Visitors now include a before() method responsible for parsing the
849
+ response body. For example, the XmlVisitor now parses the XML response into an array in the before() method.
850
+ * Fixed an issue where cURL would not automatically decompress responses when the Accept-Encoding header was sent
851
+ * CURLOPT_SSL_VERIFYHOST is never set to 1 because it is deprecated (see 5e0ff2ef20f839e19d1eeb298f90ba3598784444)
852
+ * Fixed a bug where redirect responses were not chained correctly using getPreviousResponse()
853
+ * Setting default headers on a client after setting the user-agent will not erase the user-agent setting
854
+
855
+ ## 3.1.1 - 2013-01-20
856
+
857
+ * Adding wildcard support to Guzzle\Common\Collection::getPath()
858
+ * Adding alias support to ServiceBuilder configs
859
+ * Adding Guzzle\Service\Resource\CompositeResourceIteratorFactory and cleaning up factory interface
860
+
861
+ ## 3.1.0 - 2013-01-12
862
+
863
+ * BC: CurlException now extends from RequestException rather than BadResponseException
864
+ * BC: Renamed Guzzle\Plugin\Cache\CanCacheStrategyInterface::canCache() to canCacheRequest() and added CanCacheResponse()
865
+ * Added getData to ServiceDescriptionInterface
866
+ * Added context array to RequestInterface::setState()
867
+ * Bug: Removing hard dependency on the BackoffPlugin from Guzzle\Http
868
+ * Bug: Adding required content-type when JSON request visitor adds JSON to a command
869
+ * Bug: Fixing the serialization of a service description with custom data
870
+ * Made it easier to deal with exceptions thrown when transferring commands or requests in parallel by providing
871
+ an array of successful and failed responses
872
+ * Moved getPath from Guzzle\Service\Resource\Model to Guzzle\Common\Collection
873
+ * Added Guzzle\Http\IoEmittingEntityBody
874
+ * Moved command filtration from validators to location visitors
875
+ * Added `extends` attributes to service description parameters
876
+ * Added getModels to ServiceDescriptionInterface
877
+
878
+ ## 3.0.7 - 2012-12-19
879
+
880
+ * Fixing phar detection when forcing a cacert to system if null or true
881
+ * Allowing filename to be passed to `Guzzle\Http\Message\Request::setResponseBody()`
882
+ * Cleaning up `Guzzle\Common\Collection::inject` method
883
+ * Adding a response_body location to service descriptions
884
+
885
+ ## 3.0.6 - 2012-12-09
886
+
887
+ * CurlMulti performance improvements
888
+ * Adding setErrorResponses() to Operation
889
+ * composer.json tweaks
890
+
891
+ ## 3.0.5 - 2012-11-18
892
+
893
+ * Bug: Fixing an infinite recursion bug caused from revalidating with the CachePlugin
894
+ * Bug: Response body can now be a string containing "0"
895
+ * Bug: Using Guzzle inside of a phar uses system by default but now allows for a custom cacert
896
+ * Bug: QueryString::fromString now properly parses query string parameters that contain equal signs
897
+ * Added support for XML attributes in service description responses
898
+ * DefaultRequestSerializer now supports array URI parameter values for URI template expansion
899
+ * Added better mimetype guessing to requests and post files
900
+
901
+ ## 3.0.4 - 2012-11-11
902
+
903
+ * Bug: Fixed a bug when adding multiple cookies to a request to use the correct glue value
904
+ * Bug: Cookies can now be added that have a name, domain, or value set to "0"
905
+ * Bug: Using the system cacert bundle when using the Phar
906
+ * Added json and xml methods to Response to make it easier to parse JSON and XML response data into data structures
907
+ * Enhanced cookie jar de-duplication
908
+ * Added the ability to enable strict cookie jars that throw exceptions when invalid cookies are added
909
+ * Added setStream to StreamInterface to actually make it possible to implement custom rewind behavior for entity bodies
910
+ * Added the ability to create any sort of hash for a stream rather than just an MD5 hash
911
+
912
+ ## 3.0.3 - 2012-11-04
913
+
914
+ * Implementing redirects in PHP rather than cURL
915
+ * Added PECL URI template extension and using as default parser if available
916
+ * Bug: Fixed Content-Length parsing of Response factory
917
+ * Adding rewind() method to entity bodies and streams. Allows for custom rewinding of non-repeatable streams.
918
+ * Adding ToArrayInterface throughout library
919
+ * Fixing OauthPlugin to create unique nonce values per request
920
+
921
+ ## 3.0.2 - 2012-10-25
922
+
923
+ * Magic methods are enabled by default on clients
924
+ * Magic methods return the result of a command
925
+ * Service clients no longer require a base_url option in the factory
926
+ * Bug: Fixed an issue with URI templates where null template variables were being expanded
927
+
928
+ ## 3.0.1 - 2012-10-22
929
+
930
+ * Models can now be used like regular collection objects by calling filter, map, etc.
931
+ * Models no longer require a Parameter structure or initial data in the constructor
932
+ * Added a custom AppendIterator to get around a PHP bug with the `\AppendIterator`
933
+
934
+ ## 3.0.0 - 2012-10-15
935
+
936
+ * Rewrote service description format to be based on Swagger
937
+ * Now based on JSON schema
938
+ * Added nested input structures and nested response models
939
+ * Support for JSON and XML input and output models
940
+ * Renamed `commands` to `operations`
941
+ * Removed dot class notation
942
+ * Removed custom types
943
+ * Broke the project into smaller top-level namespaces to be more component friendly
944
+ * Removed support for XML configs and descriptions. Use arrays or JSON files.
945
+ * Removed the Validation component and Inspector
946
+ * Moved all cookie code to Guzzle\Plugin\Cookie
947
+ * Magic methods on a Guzzle\Service\Client now return the command un-executed.
948
+ * Calling getResult() or getResponse() on a command will lazily execute the command if needed.
949
+ * Now shipping with cURL's CA certs and using it by default
950
+ * Added previousResponse() method to response objects
951
+ * No longer sending Accept and Accept-Encoding headers on every request
952
+ * Only sending an Expect header by default when a payload is greater than 1MB
953
+ * Added/moved client options:
954
+ * curl.blacklist to curl.option.blacklist
955
+ * Added ssl.certificate_authority
956
+ * Added a Guzzle\Iterator component
957
+ * Moved plugins from Guzzle\Http\Plugin to Guzzle\Plugin
958
+ * Added a more robust backoff retry strategy (replaced the ExponentialBackoffPlugin)
959
+ * Added a more robust caching plugin
960
+ * Added setBody to response objects
961
+ * Updating LogPlugin to use a more flexible MessageFormatter
962
+ * Added a completely revamped build process
963
+ * Cleaning up Collection class and removing default values from the get method
964
+ * Fixed ZF2 cache adapters
965
+
966
+ ## 2.8.8 - 2012-10-15
967
+
968
+ * Bug: Fixed a cookie issue that caused dot prefixed domains to not match where popular browsers did
969
+
970
+ ## 2.8.7 - 2012-09-30
971
+
972
+ * Bug: Fixed config file aliases for JSON includes
973
+ * Bug: Fixed cookie bug on a request object by using CookieParser to parse cookies on requests
974
+ * Bug: Removing the path to a file when sending a Content-Disposition header on a POST upload
975
+ * Bug: Hardening request and response parsing to account for missing parts
976
+ * Bug: Fixed PEAR packaging
977
+ * Bug: Fixed Request::getInfo
978
+ * Bug: Fixed cases where CURLM_CALL_MULTI_PERFORM return codes were causing curl transactions to fail
979
+ * Adding the ability for the namespace Iterator factory to look in multiple directories
980
+ * Added more getters/setters/removers from service descriptions
981
+ * Added the ability to remove POST fields from OAuth signatures
982
+ * OAuth plugin now supports 2-legged OAuth
983
+
984
+ ## 2.8.6 - 2012-09-05
985
+
986
+ * Added the ability to modify and build service descriptions
987
+ * Added the use of visitors to apply parameters to locations in service descriptions using the dynamic command
988
+ * Added a `json` parameter location
989
+ * Now allowing dot notation for classes in the CacheAdapterFactory
990
+ * Using the union of two arrays rather than an array_merge when extending service builder services and service params
991
+ * Ensuring that a service is a string before doing strpos() checks on it when substituting services for references
992
+ in service builder config files.
993
+ * Services defined in two different config files that include one another will by default replace the previously
994
+ defined service, but you can now create services that extend themselves and merge their settings over the previous
995
+ * The JsonLoader now supports aliasing filenames with different filenames. This allows you to alias something like
996
+ '_default' with a default JSON configuration file.
997
+
998
+ ## 2.8.5 - 2012-08-29
999
+
1000
+ * Bug: Suppressed empty arrays from URI templates
1001
+ * Bug: Added the missing $options argument from ServiceDescription::factory to enable caching
1002
+ * Added support for HTTP responses that do not contain a reason phrase in the start-line
1003
+ * AbstractCommand commands are now invokable
1004
+ * Added a way to get the data used when signing an Oauth request before a request is sent
1005
+
1006
+ ## 2.8.4 - 2012-08-15
1007
+
1008
+ * Bug: Custom delay time calculations are no longer ignored in the ExponentialBackoffPlugin
1009
+ * Added the ability to transfer entity bodies as a string rather than streamed. This gets around curl error 65. Set `body_as_string` in a request's curl options to enable.
1010
+ * Added a StreamInterface, EntityBodyInterface, and added ftell() to Guzzle\Common\Stream
1011
+ * Added an AbstractEntityBodyDecorator and a ReadLimitEntityBody decorator to transfer only a subset of a decorated stream
1012
+ * Stream and EntityBody objects will now return the file position to the previous position after a read required operation (e.g. getContentMd5())
1013
+ * Added additional response status codes
1014
+ * Removed SSL information from the default User-Agent header
1015
+ * DELETE requests can now send an entity body
1016
+ * Added an EventDispatcher to the ExponentialBackoffPlugin and added an ExponentialBackoffLogger to log backoff retries
1017
+ * Added the ability of the MockPlugin to consume mocked request bodies
1018
+ * LogPlugin now exposes request and response objects in the extras array
1019
+
1020
+ ## 2.8.3 - 2012-07-30
1021
+
1022
+ * Bug: Fixed a case where empty POST requests were sent as GET requests
1023
+ * Bug: Fixed a bug in ExponentialBackoffPlugin that caused fatal errors when retrying an EntityEnclosingRequest that does not have a body
1024
+ * Bug: Setting the response body of a request to null after completing a request, not when setting the state of a request to new
1025
+ * Added multiple inheritance to service description commands
1026
+ * Added an ApiCommandInterface and added `getParamNames()` and `hasParam()`
1027
+ * Removed the default 2mb size cutoff from the Md5ValidatorPlugin so that it now defaults to validating everything
1028
+ * Changed CurlMulti::perform to pass a smaller timeout to CurlMulti::executeHandles
1029
+
1030
+ ## 2.8.2 - 2012-07-24
1031
+
1032
+ * Bug: Query string values set to 0 are no longer dropped from the query string
1033
+ * Bug: A Collection object is no longer created each time a call is made to `Guzzle\Service\Command\AbstractCommand::getRequestHeaders()`
1034
+ * Bug: `+` is now treated as an encoded space when parsing query strings
1035
+ * QueryString and Collection performance improvements
1036
+ * Allowing dot notation for class paths in filters attribute of a service descriptions
1037
+
1038
+ ## 2.8.1 - 2012-07-16
1039
+
1040
+ * Loosening Event Dispatcher dependency
1041
+ * POST redirects can now be customized using CURLOPT_POSTREDIR
1042
+
1043
+ ## 2.8.0 - 2012-07-15
1044
+
1045
+ * BC: Guzzle\Http\Query
1046
+ * Query strings with empty variables will always show an equal sign unless the variable is set to QueryString::BLANK (e.g. ?acl= vs ?acl)
1047
+ * Changed isEncodingValues() and isEncodingFields() to isUrlEncoding()
1048
+ * Changed setEncodeValues(bool) and setEncodeFields(bool) to useUrlEncoding(bool)
1049
+ * Changed the aggregation functions of QueryString to be static methods
1050
+ * Can now use fromString() with querystrings that have a leading ?
1051
+ * cURL configuration values can be specified in service descriptions using `curl.` prefixed parameters
1052
+ * Content-Length is set to 0 before emitting the request.before_send event when sending an empty request body
1053
+ * Cookies are no longer URL decoded by default
1054
+ * Bug: URI template variables set to null are no longer expanded
1055
+
1056
+ ## 2.7.2 - 2012-07-02
1057
+
1058
+ * BC: Moving things to get ready for subtree splits. Moving Inflection into Common. Moving Guzzle\Http\Parser to Guzzle\Parser.
1059
+ * BC: Removing Guzzle\Common\Batch\Batch::count() and replacing it with isEmpty()
1060
+ * CachePlugin now allows for a custom request parameter function to check if a request can be cached
1061
+ * Bug fix: CachePlugin now only caches GET and HEAD requests by default
1062
+ * Bug fix: Using header glue when transferring headers over the wire
1063
+ * Allowing deeply nested arrays for composite variables in URI templates
1064
+ * Batch divisors can now return iterators or arrays
1065
+
1066
+ ## 2.7.1 - 2012-06-26
1067
+
1068
+ * Minor patch to update version number in UA string
1069
+ * Updating build process
1070
+
1071
+ ## 2.7.0 - 2012-06-25
1072
+
1073
+ * BC: Inflection classes moved to Guzzle\Inflection. No longer static methods. Can now inject custom inflectors into classes.
1074
+ * BC: Removed magic setX methods from commands
1075
+ * BC: Magic methods mapped to service description commands are now inflected in the command factory rather than the client __call() method
1076
+ * Verbose cURL options are no longer enabled by default. Set curl.debug to true on a client to enable.
1077
+ * Bug: Now allowing colons in a response start-line (e.g. HTTP/1.1 503 Service Unavailable: Back-end server is at capacity)
1078
+ * Guzzle\Service\Resource\ResourceIteratorApplyBatched now internally uses the Guzzle\Common\Batch namespace
1079
+ * Added Guzzle\Service\Plugin namespace and a PluginCollectionPlugin
1080
+ * Added the ability to set POST fields and files in a service description
1081
+ * Guzzle\Http\EntityBody::factory() now accepts objects with a __toString() method
1082
+ * Adding a command.before_prepare event to clients
1083
+ * Added BatchClosureTransfer and BatchClosureDivisor
1084
+ * BatchTransferException now includes references to the batch divisor and transfer strategies
1085
+ * Fixed some tests so that they pass more reliably
1086
+ * Added Guzzle\Common\Log\ArrayLogAdapter
1087
+
1088
+ ## 2.6.6 - 2012-06-10
1089
+
1090
+ * BC: Removing Guzzle\Http\Plugin\BatchQueuePlugin
1091
+ * BC: Removing Guzzle\Service\Command\CommandSet
1092
+ * Adding generic batching system (replaces the batch queue plugin and command set)
1093
+ * Updating ZF cache and log adapters and now using ZF's composer repository
1094
+ * Bug: Setting the name of each ApiParam when creating through an ApiCommand
1095
+ * Adding result_type, result_doc, deprecated, and doc_url to service descriptions
1096
+ * Bug: Changed the default cookie header casing back to 'Cookie'
1097
+
1098
+ ## 2.6.5 - 2012-06-03
1099
+
1100
+ * BC: Renaming Guzzle\Http\Message\RequestInterface::getResourceUri() to getResource()
1101
+ * BC: Removing unused AUTH_BASIC and AUTH_DIGEST constants from
1102
+ * BC: Guzzle\Http\Cookie is now used to manage Set-Cookie data, not Cookie data
1103
+ * BC: Renaming methods in the CookieJarInterface
1104
+ * Moving almost all cookie logic out of the CookiePlugin and into the Cookie or CookieJar implementations
1105
+ * Making the default glue for HTTP headers ';' instead of ','
1106
+ * Adding a removeValue to Guzzle\Http\Message\Header
1107
+ * Adding getCookies() to request interface.
1108
+ * Making it easier to add event subscribers to HasDispatcherInterface classes. Can now directly call addSubscriber()
1109
+
1110
+ ## 2.6.4 - 2012-05-30
1111
+
1112
+ * BC: Cleaning up how POST files are stored in EntityEnclosingRequest objects. Adding PostFile class.
1113
+ * BC: Moving ApiCommand specific functionality from the Inspector and on to the ApiCommand
1114
+ * Bug: Fixing magic method command calls on clients
1115
+ * Bug: Email constraint only validates strings
1116
+ * Bug: Aggregate POST fields when POST files are present in curl handle
1117
+ * Bug: Fixing default User-Agent header
1118
+ * Bug: Only appending or prepending parameters in commands if they are specified
1119
+ * Bug: Not requiring response reason phrases or status codes to match a predefined list of codes
1120
+ * Allowing the use of dot notation for class namespaces when using instance_of constraint
1121
+ * Added any_match validation constraint
1122
+ * Added an AsyncPlugin
1123
+ * Passing request object to the calculateWait method of the ExponentialBackoffPlugin
1124
+ * Allowing the result of a command object to be changed
1125
+ * Parsing location and type sub values when instantiating a service description rather than over and over at runtime
1126
+
1127
+ ## 2.6.3 - 2012-05-23
1128
+
1129
+ * [BC] Guzzle\Common\FromConfigInterface no longer requires any config options.
1130
+ * [BC] Refactoring how POST files are stored on an EntityEnclosingRequest. They are now separate from POST fields.
1131
+ * You can now use an array of data when creating PUT request bodies in the request factory.
1132
+ * Removing the requirement that HTTPS requests needed a Cache-Control: public directive to be cacheable.
1133
+ * [Http] Adding support for Content-Type in multipart POST uploads per upload
1134
+ * [Http] Added support for uploading multiple files using the same name (foo[0], foo[1])
1135
+ * Adding more POST data operations for easier manipulation of POST data.
1136
+ * You can now set empty POST fields.
1137
+ * The body of a request is only shown on EntityEnclosingRequest objects that do not use POST files.
1138
+ * Split the Guzzle\Service\Inspector::validateConfig method into two methods. One to initialize when a command is created, and one to validate.
1139
+ * CS updates
1140
+
1141
+ ## 2.6.2 - 2012-05-19
1142
+
1143
+ * [Http] Better handling of nested scope requests in CurlMulti. Requests are now always prepares in the send() method rather than the addRequest() method.
1144
+
1145
+ ## 2.6.1 - 2012-05-19
1146
+
1147
+ * [BC] Removing 'path' support in service descriptions. Use 'uri'.
1148
+ * [BC] Guzzle\Service\Inspector::parseDocBlock is now protected. Adding getApiParamsForClass() with cache.
1149
+ * [BC] Removing Guzzle\Common\NullObject. Use https://github.com/mtdowling/NullObject if you need it.
1150
+ * [BC] Removing Guzzle\Common\XmlElement.
1151
+ * All commands, both dynamic and concrete, have ApiCommand objects.
1152
+ * Adding a fix for CurlMulti so that if all of the connections encounter some sort of curl error, then the loop exits.
1153
+ * Adding checks to EntityEnclosingRequest so that empty POST files and fields are ignored.
1154
+ * Making the method signature of Guzzle\Service\Builder\ServiceBuilder::factory more flexible.
1155
+
1156
+ ## 2.6.0 - 2012-05-15
1157
+
1158
+ * [BC] Moving Guzzle\Service\Builder to Guzzle\Service\Builder\ServiceBuilder
1159
+ * [BC] Executing a Command returns the result of the command rather than the command
1160
+ * [BC] Moving all HTTP parsing logic to Guzzle\Http\Parsers. Allows for faster C implementations if needed.
1161
+ * [BC] Changing the Guzzle\Http\Message\Response::setProtocol() method to accept a protocol and version in separate args.
1162
+ * [BC] Moving ResourceIterator* to Guzzle\Service\Resource
1163
+ * [BC] Completely refactored ResourceIterators to iterate over a cloned command object
1164
+ * [BC] Moved Guzzle\Http\UriTemplate to Guzzle\Http\Parser\UriTemplate\UriTemplate
1165
+ * [BC] Guzzle\Guzzle is now deprecated
1166
+ * Moving Guzzle\Common\Guzzle::inject to Guzzle\Common\Collection::inject
1167
+ * Adding Guzzle\Version class to give version information about Guzzle
1168
+ * Adding Guzzle\Http\Utils class to provide getDefaultUserAgent() and getHttpDate()
1169
+ * Adding Guzzle\Curl\CurlVersion to manage caching curl_version() data
1170
+ * ServiceDescription and ServiceBuilder are now cacheable using similar configs
1171
+ * Changing the format of XML and JSON service builder configs. Backwards compatible.
1172
+ * Cleaned up Cookie parsing
1173
+ * Trimming the default Guzzle User-Agent header
1174
+ * Adding a setOnComplete() method to Commands that is called when a command completes
1175
+ * Keeping track of requests that were mocked in the MockPlugin
1176
+ * Fixed a caching bug in the CacheAdapterFactory
1177
+ * Inspector objects can be injected into a Command object
1178
+ * Refactoring a lot of code and tests to be case insensitive when dealing with headers
1179
+ * Adding Guzzle\Http\Message\HeaderComparison for easy comparison of HTTP headers using a DSL
1180
+ * Adding the ability to set global option overrides to service builder configs
1181
+ * Adding the ability to include other service builder config files from within XML and JSON files
1182
+ * Moving the parseQuery method out of Url and on to QueryString::fromString() as a static factory method.
1183
+
1184
+ ## 2.5.0 - 2012-05-08
1185
+
1186
+ * Major performance improvements
1187
+ * [BC] Simplifying Guzzle\Common\Collection. Please check to see if you are using features that are now deprecated.
1188
+ * [BC] Using a custom validation system that allows a flyweight implementation for much faster validation. No longer using Symfony2 Validation component.
1189
+ * [BC] No longer supporting "{{ }}" for injecting into command or UriTemplates. Use "{}"
1190
+ * Added the ability to passed parameters to all requests created by a client
1191
+ * Added callback functionality to the ExponentialBackoffPlugin
1192
+ * Using microtime in ExponentialBackoffPlugin to allow more granular backoff strategies.
1193
+ * Rewinding request stream bodies when retrying requests
1194
+ * Exception is thrown when JSON response body cannot be decoded
1195
+ * Added configurable magic method calls to clients and commands. This is off by default.
1196
+ * Fixed a defect that added a hash to every parsed URL part
1197
+ * Fixed duplicate none generation for OauthPlugin.
1198
+ * Emitting an event each time a client is generated by a ServiceBuilder
1199
+ * Using an ApiParams object instead of a Collection for parameters of an ApiCommand
1200
+ * cache.* request parameters should be renamed to params.cache.*
1201
+ * Added the ability to set arbitrary curl options on requests (disable_wire, progress, etc.). See CurlHandle.
1202
+ * Added the ability to disable type validation of service descriptions
1203
+ * ServiceDescriptions and ServiceBuilders are now Serializable
app/api/Ctct/vendor/guzzlehttp/guzzle/LICENSE ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Copyright (c) 2011-2015 Michael Dowling, https://github.com/mtdowling <mtdowling@gmail.com>
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.
app/api/Ctct/vendor/guzzlehttp/guzzle/README.md ADDED
@@ -0,0 +1,90 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Guzzle, PHP HTTP client
2
+ =======================
3
+
4
+ [![Build Status](https://secure.travis-ci.org/guzzle/guzzle.svg?branch=master)](http://travis-ci.org/guzzle/guzzle)
5
+
6
+ Guzzle is a PHP HTTP client that makes it easy to send HTTP requests and
7
+ trivial to integrate with web services.
8
+
9
+ - Simple interface for building query strings, POST requests, streaming large
10
+ uploads, streaming large downloads, using HTTP cookies, uploading JSON data,
11
+ etc...
12
+ - Can send both synchronous and asynchronous requests using the same interface.
13
+ - Uses PSR-7 interfaces for requests, responses, and streams. This allows you
14
+ to utilize other PSR-7 compatible libraries with Guzzle.
15
+ - Abstracts away the underlying HTTP transport, allowing you to write
16
+ environment and transport agnostic code; i.e., no hard dependency on cURL,
17
+ PHP streams, sockets, or non-blocking event loops.
18
+ - Middleware system allows you to augment and compose client behavior.
19
+
20
+ ```php
21
+ $client = new GuzzleHttp\Client();
22
+ $res = $client->request('GET', 'https://api.github.com/user', [
23
+ 'auth' => ['user', 'pass']
24
+ ]);
25
+ echo $res->getStatusCode();
26
+ // 200
27
+ echo $res->getHeader('content-type');
28
+ // 'application/json; charset=utf8'
29
+ echo $res->getBody();
30
+ // {"type":"User"...'
31
+
32
+ // Send an asynchronous request.
33
+ $request = new \GuzzleHttp\Psr7\Request('GET', 'http://httpbin.org');
34
+ $promise = $client->sendAsync($request)->then(function ($response) {
35
+ echo 'I completed! ' . $response->getBody();
36
+ });
37
+ $promise->wait();
38
+ ```
39
+
40
+ ## Help and docs
41
+
42
+ - [Documentation](http://guzzlephp.org/)
43
+ - [stackoverflow](http://stackoverflow.com/questions/tagged/guzzle)
44
+ - [Gitter](https://gitter.im/guzzle/guzzle)
45
+
46
+
47
+ ## Installing Guzzle
48
+
49
+ The recommended way to install Guzzle is through
50
+ [Composer](http://getcomposer.org).
51
+
52
+ ```bash
53
+ # Install Composer
54
+ curl -sS https://getcomposer.org/installer | php
55
+ ```
56
+
57
+ Next, run the Composer command to install the latest stable version of Guzzle:
58
+
59
+ ```bash
60
+ composer.phar require guzzlehttp/guzzle
61
+ ```
62
+
63
+ After installing, you need to require Composer's autoloader:
64
+
65
+ ```php
66
+ require 'vendor/autoload.php';
67
+ ```
68
+
69
+ You can then later update Guzzle using composer:
70
+
71
+ ```bash
72
+ composer.phar update
73
+ ```
74
+
75
+
76
+ ## Version Guidance
77
+
78
+ | Version | Status | Packagist | Namespace | Repo | Docs | PSR-7 |
79
+ |---------|-------------|---------------------|--------------|---------------------|---------------------|-------|
80
+ | 3.x | EOL | `guzzle/guzzle` | `Guzzle` | [v3][guzzle-3-repo] | [v3][guzzle-3-docs] | No |
81
+ | 4.x | EOL | `guzzlehttp/guzzle` | `GuzzleHttp` | N/A | N/A | No |
82
+ | 5.x | Maintained | `guzzlehttp/guzzle` | `GuzzleHttp` | [v5][guzzle-5-repo] | [v5][guzzle-5-docs] | No |
83
+ | 6.x | Latest | `guzzlehttp/guzzle` | `GuzzleHttp` | [v6][guzzle-6-repo] | [v6][guzzle-6-docs] | Yes |
84
+
85
+ [guzzle-3-repo]: https://github.com/guzzle/guzzle3
86
+ [guzzle-5-repo]: https://github.com/guzzle/guzzle/tree/5.3
87
+ [guzzle-6-repo]: https://github.com/guzzle/guzzle
88
+ [guzzle-3-docs]: http://guzzle3.readthedocs.org/en/latest/
89
+ [guzzle-5-docs]: http://guzzle.readthedocs.org/en/5.3/
90
+ [guzzle-6-docs]: http://guzzle.readthedocs.org/en/latest/
app/api/Ctct/vendor/guzzlehttp/guzzle/UPGRADING.md ADDED
@@ -0,0 +1,1203 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Guzzle Upgrade Guide
2
+ ====================
3
+
4
+ 5.0 to 6.0
5
+ ----------
6
+
7
+ Guzzle now uses [PSR-7](http://www.php-fig.org/psr/psr-7/) for HTTP messages.
8
+ Due to the fact that these messages are immutable, this prompted a refactoring
9
+ of Guzzle to use a middleware based system rather than an event system. Any
10
+ HTTP message interaction (e.g., `GuzzleHttp\Message\Request`) need to be
11
+ updated to work with the new immutable PSR-7 request and response objects. Any
12
+ event listeners or subscribers need to be updated to become middleware
13
+ functions that wrap handlers (or are injected into a
14
+ `GuzzleHttp\HandlerStack`).
15
+
16
+ - Removed `GuzzleHttp\BatchResults`
17
+ - Removed `GuzzleHttp\Collection`
18
+ - Removed `GuzzleHttp\HasDataTrait`
19
+ - Removed `GuzzleHttp\ToArrayInterface`
20
+ - The `guzzlehttp/streams` dependency has been removed. Stream functionality
21
+ is now present in the `GuzzleHttp\Psr7` namespace provided by the
22
+ `guzzlehttp/psr7` package.
23
+ - Guzzle no longer uses ReactPHP promises and now uses the
24
+ `guzzlehttp/promises` library. We use a custom promise library for three
25
+ significant reasons:
26
+ 1. React promises (at the time of writing this) are recursive. Promise
27
+ chaining and promise resolution will eventually blow the stack. Guzzle
28
+ promises are not recursive as they use a sort of trampolining technique.
29
+ Note: there has been movement in the React project to modify promises to
30
+ no longer utilize recursion.
31
+ 2. Guzzle needs to have the ability to synchronously block on a promise to
32
+ wait for a result. Guzzle promises allows this functionality (and does
33
+ not require the use of recursion).
34
+ 3. Because we need to be able to wait on a result, doing so using React
35
+ promises requires wrapping react promises with RingPHP futures. This
36
+ overhead is no longer needed, reducing stack sizes, reducing complexity,
37
+ and improving performance.
38
+ - `GuzzleHttp\Mimetypes` has been moved to a function in
39
+ `GuzzleHttp\Psr7\mimetype_from_extension` and
40
+ `GuzzleHttp\Psr7\mimetype_from_filename`.
41
+ - `GuzzleHttp\Query` and `GuzzleHttp\QueryParser` have been removed. Query
42
+ strings must now be passed into request objects as strings, or provided to
43
+ the `query` request option when creating requests with clients. The `query`
44
+ option uses PHP's `http_build_query` to convert an array to a string. If you
45
+ need a different serialization technique, you will need to pass the query
46
+ string in as a string. There are a couple helper functions that will make
47
+ working with query strings easier: `GuzzleHttp\Psr7\parse_query` and
48
+ `GuzzleHttp\Psr7\build_query`.
49
+ - Guzzle no longer has a dependency on RingPHP. Due to the use of a middleware
50
+ system based on PSR-7, using RingPHP and it's middleware system as well adds
51
+ more complexity than the benefits it provides. All HTTP handlers that were
52
+ present in RingPHP have been modified to work directly with PSR-7 messages
53
+ and placed in the `GuzzleHttp\Handler` namespace. This significantly reduces
54
+ complexity in Guzzle, removes a dependency, and improves performance. RingPHP
55
+ will be maintained for Guzzle 5 support, but will no longer be a part of
56
+ Guzzle 6.
57
+ - As Guzzle now uses a middleware based systems the event system and RingPHP
58
+ integration has been removed. Note: while the event system has been removed,
59
+ it is possible to add your own type of event system that is powered by the
60
+ middleware system.
61
+ - Removed the `Event` namespace.
62
+ - Removed the `Subscriber` namespace.
63
+ - Removed `Transaction` class
64
+ - Removed `RequestFsm`
65
+ - Removed `RingBridge`
66
+ - `GuzzleHttp\Subscriber\Cookie` is now provided by
67
+ `GuzzleHttp\Middleware::cookies`
68
+ - `GuzzleHttp\Subscriber\HttpError` is now provided by
69
+ `GuzzleHttp\Middleware::httpError`
70
+ - `GuzzleHttp\Subscriber\History` is now provided by
71
+ `GuzzleHttp\Middleware::history`
72
+ - `GuzzleHttp\Subscriber\Mock` is now provided by
73
+ `GuzzleHttp\Handler\MockHandler`
74
+ - `GuzzleHttp\Subscriber\Prepare` is now provided by
75
+ `GuzzleHttp\PrepareBodyMiddleware`
76
+ - `GuzzleHttp\Subscriber\Redirect` is now provided by
77
+ `GuzzleHttp\RedirectMiddleware`
78
+ - Guzzle now uses `Psr\Http\Message\UriInterface` (implements in
79
+ `GuzzleHttp\Psr7\Uri`) for URI support. `GuzzleHttp\Url` is now gone.
80
+ - Static functions in `GuzzleHttp\Utils` have been moved to namespaced
81
+ functions under the `GuzzleHttp` namespace. This requires either a Composer
82
+ based autoloader or you to include functions.php.
83
+ - `GuzzleHttp\ClientInterface::getDefaultOption` has been renamed to
84
+ `GuzzleHttp\ClientInterface::getConfig`.
85
+ - `GuzzleHttp\ClientInterface::setDefaultOption` has been removed.
86
+ - The `json` and `xml` methods of response objects has been removed. With the
87
+ migration to strictly adhering to PSR-7 as the interface for Guzzle messages,
88
+ adding methods to message interfaces would actually require Guzzle messages
89
+ to extend from PSR-7 messages rather then work with them directly.
90
+
91
+ ## Migrating to middleware
92
+
93
+ The change to PSR-7 unfortunately required significant refactoring to Guzzle
94
+ due to the fact that PSR-7 messages are immutable. Guzzle 5 relied on an event
95
+ system from plugins. The event system relied on mutability of HTTP messages and
96
+ side effects in order to work. With immutable messages, you have to change your
97
+ workflow to become more about either returning a value (e.g., functional
98
+ middlewares) or setting a value on an object. Guzzle v6 has chosen the
99
+ functional middleware approach.
100
+
101
+ Instead of using the event system to listen for things like the `before` event,
102
+ you now create a stack based middleware function that intercepts a request on
103
+ the way in and the promise of the response on the way out. This is a much
104
+ simpler and more predictable approach than the event system and works nicely
105
+ with PSR-7 middleware. Due to the use of promises, the middleware system is
106
+ also asynchronous.
107
+
108
+ v5:
109
+
110
+ ```php
111
+ use GuzzleHttp\Event\BeforeEvent;
112
+ $client = new GuzzleHttp\Client();
113
+ // Get the emitter and listen to the before event.
114
+ $client->getEmitter()->on('before', function (BeforeEvent $e) {
115
+ // Guzzle v5 events relied on mutation
116
+ $e->getRequest()->setHeader('X-Foo', 'Bar');
117
+ });
118
+ ```
119
+
120
+ v6:
121
+
122
+ In v6, you can modify the request before it is sent using the `mapRequest`
123
+ middleware. The idiomatic way in v6 to modify the request/response lifecycle is
124
+ to setup a handler middleware stack up front and inject the handler into a
125
+ client.
126
+
127
+ ```php
128
+ use GuzzleHttp\Middleware;
129
+ // Create a handler stack that has all of the default middlewares attached
130
+ $handler = GuzzleHttp\HandlerStack::create();
131
+ // Push the handler onto the handler stack
132
+ $handler->push(Middleware::mapRequest(function (RequestInterface $request) {
133
+ // Notice that we have to return a request object
134
+ return $request->withHeader('X-Foo', 'Bar');
135
+ });
136
+ // Inject the handler into the client
137
+ $client = new GuzzleHttp\Client(['handler' => $handler]);
138
+ ```
139
+
140
+ ## POST Requests
141
+
142
+ This version added the [`form_params`](http://guzzle.readthedocs.org/en/latest/request-options.html#form_params)
143
+ and `multipart` request options. `form_params` is an associative array of
144
+ strings or array of strings and is used to serialize an
145
+ `application/x-www-form-urlencoded` POST request. The
146
+ [`multipart`](http://guzzle.readthedocs.org/en/latest/request-options.html#multipart)
147
+ option is now used to send a multipart/form-data POST request.
148
+
149
+ `GuzzleHttp\Post\PostFile` has been removed. Use the `multipart` option to add
150
+ POST files to a multipart/form-data request.
151
+
152
+ The `body` option no longer accepts an array to send POST requests. Please use
153
+ `multipart` or `form_params` instead.
154
+
155
+ The `base_url` option has been renamed to `base_uri`.
156
+
157
+ 4.x to 5.0
158
+ ----------
159
+
160
+ ## Rewritten Adapter Layer
161
+
162
+ Guzzle now uses [RingPHP](http://ringphp.readthedocs.org/en/latest) to send
163
+ HTTP requests. The `adapter` option in a `GuzzleHttp\Client` constructor
164
+ is still supported, but it has now been renamed to `handler`. Instead of
165
+ passing a `GuzzleHttp\Adapter\AdapterInterface`, you must now pass a PHP
166
+ `callable` that follows the RingPHP specification.
167
+
168
+ ## Removed Fluent Interfaces
169
+
170
+ [Fluent interfaces were removed](http://ocramius.github.io/blog/fluent-interfaces-are-evil)
171
+ from the following classes:
172
+
173
+ - `GuzzleHttp\Collection`
174
+ - `GuzzleHttp\Url`
175
+ - `GuzzleHttp\Query`
176
+ - `GuzzleHttp\Post\PostBody`
177
+ - `GuzzleHttp\Cookie\SetCookie`
178
+
179
+ ## Removed functions.php
180
+
181
+ Removed "functions.php", so that Guzzle is truly PSR-4 compliant. The following
182
+ functions can be used as replacements.
183
+
184
+ - `GuzzleHttp\json_decode` -> `GuzzleHttp\Utils::jsonDecode`
185
+ - `GuzzleHttp\get_path` -> `GuzzleHttp\Utils::getPath`
186
+ - `GuzzleHttp\Utils::setPath` -> `GuzzleHttp\set_path`
187
+ - `GuzzleHttp\Pool::batch` -> `GuzzleHttp\batch`. This function is, however,
188
+ deprecated in favor of using `GuzzleHttp\Pool::batch()`.
189
+
190
+ The "procedural" global client has been removed with no replacement (e.g.,
191
+ `GuzzleHttp\get()`, `GuzzleHttp\post()`, etc.). Use a `GuzzleHttp\Client`
192
+ object as a replacement.
193
+
194
+ ## `throwImmediately` has been removed
195
+
196
+ The concept of "throwImmediately" has been removed from exceptions and error
197
+ events. This control mechanism was used to stop a transfer of concurrent
198
+ requests from completing. This can now be handled by throwing the exception or
199
+ by cancelling a pool of requests or each outstanding future request
200
+ individually.
201
+
202
+ ## headers event has been removed
203
+
204
+ Removed the "headers" event. This event was only useful for changing the
205
+ body a response once the headers of the response were known. You can implement
206
+ a similar behavior in a number of ways. One example might be to use a
207
+ FnStream that has access to the transaction being sent. For example, when the
208
+ first byte is written, you could check if the response headers match your
209
+ expectations, and if so, change the actual stream body that is being
210
+ written to.
211
+
212
+ ## Updates to HTTP Messages
213
+
214
+ Removed the `asArray` parameter from
215
+ `GuzzleHttp\Message\MessageInterface::getHeader`. If you want to get a header
216
+ value as an array, then use the newly added `getHeaderAsArray()` method of
217
+ `MessageInterface`. This change makes the Guzzle interfaces compatible with
218
+ the PSR-7 interfaces.
219
+
220
+ 3.x to 4.0
221
+ ----------
222
+
223
+ ## Overarching changes:
224
+
225
+ - Now requires PHP 5.4 or greater.
226
+ - No longer requires cURL to send requests.
227
+ - Guzzle no longer wraps every exception it throws. Only exceptions that are
228
+ recoverable are now wrapped by Guzzle.
229
+ - Various namespaces have been removed or renamed.
230
+ - No longer requiring the Symfony EventDispatcher. A custom event dispatcher
231
+ based on the Symfony EventDispatcher is
232
+ now utilized in `GuzzleHttp\Event\EmitterInterface` (resulting in significant
233
+ speed and functionality improvements).
234
+
235
+ Changes per Guzzle 3.x namespace are described below.
236
+
237
+ ## Batch
238
+
239
+ The `Guzzle\Batch` namespace has been removed. This is best left to
240
+ third-parties to implement on top of Guzzle's core HTTP library.
241
+
242
+ ## Cache
243
+
244
+ The `Guzzle\Cache` namespace has been removed. (Todo: No suitable replacement
245
+ has been implemented yet, but hoping to utilize a PSR cache interface).
246
+
247
+ ## Common
248
+
249
+ - Removed all of the wrapped exceptions. It's better to use the standard PHP
250
+ library for unrecoverable exceptions.
251
+ - `FromConfigInterface` has been removed.
252
+ - `Guzzle\Common\Version` has been removed. The VERSION constant can be found
253
+ at `GuzzleHttp\ClientInterface::VERSION`.
254
+
255
+ ### Collection
256
+
257
+ - `getAll` has been removed. Use `toArray` to convert a collection to an array.
258
+ - `inject` has been removed.
259
+ - `keySearch` has been removed.
260
+ - `getPath` no longer supports wildcard expressions. Use something better like
261
+ JMESPath for this.
262
+ - `setPath` now supports appending to an existing array via the `[]` notation.
263
+
264
+ ### Events
265
+
266
+ Guzzle no longer requires Symfony's EventDispatcher component. Guzzle now uses
267
+ `GuzzleHttp\Event\Emitter`.
268
+
269
+ - `Symfony\Component\EventDispatcher\EventDispatcherInterface` is replaced by
270
+ `GuzzleHttp\Event\EmitterInterface`.
271
+ - `Symfony\Component\EventDispatcher\EventDispatcher` is replaced by
272
+ `GuzzleHttp\Event\Emitter`.
273
+ - `Symfony\Component\EventDispatcher\Event` is replaced by
274
+ `GuzzleHttp\Event\Event`, and Guzzle now has an EventInterface in
275
+ `GuzzleHttp\Event\EventInterface`.
276
+ - `AbstractHasDispatcher` has moved to a trait, `HasEmitterTrait`, and
277
+ `HasDispatcherInterface` has moved to `HasEmitterInterface`. Retrieving the
278
+ event emitter of a request, client, etc. now uses the `getEmitter` method
279
+ rather than the `getDispatcher` method.
280
+
281
+ #### Emitter
282
+
283
+ - Use the `once()` method to add a listener that automatically removes itself
284
+ the first time it is invoked.
285
+ - Use the `listeners()` method to retrieve a list of event listeners rather than
286
+ the `getListeners()` method.
287
+ - Use `emit()` instead of `dispatch()` to emit an event from an emitter.
288
+ - Use `attach()` instead of `addSubscriber()` and `detach()` instead of
289
+ `removeSubscriber()`.
290
+
291
+ ```php
292
+ $mock = new Mock();
293
+ // 3.x
294
+ $request->getEventDispatcher()->addSubscriber($mock);
295
+ $request->getEventDispatcher()->removeSubscriber($mock);
296
+ // 4.x
297
+ $request->getEmitter()->attach($mock);
298
+ $request->getEmitter()->detach($mock);
299
+ ```
300
+
301
+ Use the `on()` method to add a listener rather than the `addListener()` method.
302
+
303
+ ```php
304
+ // 3.x
305
+ $request->getEventDispatcher()->addListener('foo', function (Event $event) { /* ... */ } );
306
+ // 4.x
307
+ $request->getEmitter()->on('foo', function (Event $event, $name) { /* ... */ } );
308
+ ```
309
+
310
+ ## Http
311
+
312
+ ### General changes
313
+
314
+ - The cacert.pem certificate has been moved to `src/cacert.pem`.
315
+ - Added the concept of adapters that are used to transfer requests over the
316
+ wire.
317
+ - Simplified the event system.
318
+ - Sending requests in parallel is still possible, but batching is no longer a
319
+ concept of the HTTP layer. Instead, you must use the `complete` and `error`
320
+ events to asynchronously manage parallel request transfers.
321
+ - `Guzzle\Http\Url` has moved to `GuzzleHttp\Url`.
322
+ - `Guzzle\Http\QueryString` has moved to `GuzzleHttp\Query`.
323
+ - QueryAggregators have been rewritten so that they are simply callable
324
+ functions.
325
+ - `GuzzleHttp\StaticClient` has been removed. Use the functions provided in
326
+ `functions.php` for an easy to use static client instance.
327
+ - Exceptions in `GuzzleHttp\Exception` have been updated to all extend from
328
+ `GuzzleHttp\Exception\TransferException`.
329
+
330
+ ### Client
331
+
332
+ Calling methods like `get()`, `post()`, `head()`, etc. no longer create and
333
+ return a request, but rather creates a request, sends the request, and returns
334
+ the response.
335
+
336
+ ```php
337
+ // 3.0
338
+ $request = $client->get('/');
339
+ $response = $request->send();
340
+
341
+ // 4.0
342
+ $response = $client->get('/');
343
+
344
+ // or, to mirror the previous behavior
345
+ $request = $client->createRequest('GET', '/');
346
+ $response = $client->send($request);
347
+ ```
348
+
349
+ `GuzzleHttp\ClientInterface` has changed.
350
+
351
+ - The `send` method no longer accepts more than one request. Use `sendAll` to
352
+ send multiple requests in parallel.
353
+ - `setUserAgent()` has been removed. Use a default request option instead. You
354
+ could, for example, do something like:
355
+ `$client->setConfig('defaults/headers/User-Agent', 'Foo/Bar ' . $client::getDefaultUserAgent())`.
356
+ - `setSslVerification()` has been removed. Use default request options instead,
357
+ like `$client->setConfig('defaults/verify', true)`.
358
+
359
+ `GuzzleHttp\Client` has changed.
360
+
361
+ - The constructor now accepts only an associative array. You can include a
362
+ `base_url` string or array to use a URI template as the base URL of a client.
363
+ You can also specify a `defaults` key that is an associative array of default
364
+ request options. You can pass an `adapter` to use a custom adapter,
365
+ `batch_adapter` to use a custom adapter for sending requests in parallel, or
366
+ a `message_factory` to change the factory used to create HTTP requests and
367
+ responses.
368
+ - The client no longer emits a `client.create_request` event.
369
+ - Creating requests with a client no longer automatically utilize a URI
370
+ template. You must pass an array into a creational method (e.g.,
371
+ `createRequest`, `get`, `put`, etc.) in order to expand a URI template.
372
+
373
+ ### Messages
374
+
375
+ Messages no longer have references to their counterparts (i.e., a request no
376
+ longer has a reference to it's response, and a response no loger has a
377
+ reference to its request). This association is now managed through a
378
+ `GuzzleHttp\Adapter\TransactionInterface` object. You can get references to
379
+ these transaction objects using request events that are emitted over the
380
+ lifecycle of a request.
381
+
382
+ #### Requests with a body
383
+
384
+ - `GuzzleHttp\Message\EntityEnclosingRequest` and
385
+ `GuzzleHttp\Message\EntityEnclosingRequestInterface` have been removed. The
386
+ separation between requests that contain a body and requests that do not
387
+ contain a body has been removed, and now `GuzzleHttp\Message\RequestInterface`
388
+ handles both use cases.
389
+ - Any method that previously accepts a `GuzzleHttp\Response` object now accept a
390
+ `GuzzleHttp\Message\ResponseInterface`.
391
+ - `GuzzleHttp\Message\RequestFactoryInterface` has been renamed to
392
+ `GuzzleHttp\Message\MessageFactoryInterface`. This interface is used to create
393
+ both requests and responses and is implemented in
394
+ `GuzzleHttp\Message\MessageFactory`.
395
+ - POST field and file methods have been removed from the request object. You
396
+ must now use the methods made available to `GuzzleHttp\Post\PostBodyInterface`
397
+ to control the format of a POST body. Requests that are created using a
398
+ standard `GuzzleHttp\Message\MessageFactoryInterface` will automatically use
399
+ a `GuzzleHttp\Post\PostBody` body if the body was passed as an array or if
400
+ the method is POST and no body is provided.
401
+
402
+ ```php
403
+ $request = $client->createRequest('POST', '/');
404
+ $request->getBody()->setField('foo', 'bar');
405
+ $request->getBody()->addFile(new PostFile('file_key', fopen('/path/to/content', 'r')));
406
+ ```
407
+
408
+ #### Headers
409
+
410
+ - `GuzzleHttp\Message\Header` has been removed. Header values are now simply
411
+ represented by an array of values or as a string. Header values are returned
412
+ as a string by default when retrieving a header value from a message. You can
413
+ pass an optional argument of `true` to retrieve a header value as an array
414
+ of strings instead of a single concatenated string.
415
+ - `GuzzleHttp\PostFile` and `GuzzleHttp\PostFileInterface` have been moved to
416
+ `GuzzleHttp\Post`. This interface has been simplified and now allows the
417
+ addition of arbitrary headers.
418
+ - Custom headers like `GuzzleHttp\Message\Header\Link` have been removed. Most
419
+ of the custom headers are now handled separately in specific
420
+ subscribers/plugins, and `GuzzleHttp\Message\HeaderValues::parseParams()` has
421
+ been updated to properly handle headers that contain parameters (like the
422
+ `Link` header).
423
+
424
+ #### Responses
425
+
426
+ - `GuzzleHttp\Message\Response::getInfo()` and
427
+ `GuzzleHttp\Message\Response::setInfo()` have been removed. Use the event
428
+ system to retrieve this type of information.
429
+ - `GuzzleHttp\Message\Response::getRawHeaders()` has been removed.
430
+ - `GuzzleHttp\Message\Response::getMessage()` has been removed.
431
+ - `GuzzleHttp\Message\Response::calculateAge()` and other cache specific
432
+ methods have moved to the CacheSubscriber.
433
+ - Header specific helper functions like `getContentMd5()` have been removed.
434
+ Just use `getHeader('Content-MD5')` instead.
435
+ - `GuzzleHttp\Message\Response::setRequest()` and
436
+ `GuzzleHttp\Message\Response::getRequest()` have been removed. Use the event
437
+ system to work with request and response objects as a transaction.
438
+ - `GuzzleHttp\Message\Response::getRedirectCount()` has been removed. Use the
439
+ Redirect subscriber instead.
440
+ - `GuzzleHttp\Message\Response::isSuccessful()` and other related methods have
441
+ been removed. Use `getStatusCode()` instead.
442
+
443
+ #### Streaming responses
444
+
445
+ Streaming requests can now be created by a client directly, returning a
446
+ `GuzzleHttp\Message\ResponseInterface` object that contains a body stream
447
+ referencing an open PHP HTTP stream.
448
+
449
+ ```php
450
+ // 3.0
451
+ use Guzzle\Stream\PhpStreamRequestFactory;
452
+ $request = $client->get('/');
453
+ $factory = new PhpStreamRequestFactory();
454
+ $stream = $factory->fromRequest($request);
455
+ $data = $stream->read(1024);
456
+
457
+ // 4.0
458
+ $response = $client->get('/', ['stream' => true]);
459
+ // Read some data off of the stream in the response body
460
+ $data = $response->getBody()->read(1024);
461
+ ```
462
+
463
+ #### Redirects
464
+
465
+ The `configureRedirects()` method has been removed in favor of a
466
+ `allow_redirects` request option.
467
+
468
+ ```php
469
+ // Standard redirects with a default of a max of 5 redirects
470
+ $request = $client->createRequest('GET', '/', ['allow_redirects' => true]);
471
+
472
+ // Strict redirects with a custom number of redirects
473
+ $request = $client->createRequest('GET', '/', [
474
+ 'allow_redirects' => ['max' => 5, 'strict' => true]
475
+ ]);
476
+ ```
477
+
478
+ #### EntityBody
479
+
480
+ EntityBody interfaces and classes have been removed or moved to
481
+ `GuzzleHttp\Stream`. All classes and interfaces that once required
482
+ `GuzzleHttp\EntityBodyInterface` now require
483
+ `GuzzleHttp\Stream\StreamInterface`. Creating a new body for a request no
484
+ longer uses `GuzzleHttp\EntityBody::factory` but now uses
485
+ `GuzzleHttp\Stream\Stream::factory` or even better:
486
+ `GuzzleHttp\Stream\create()`.
487
+
488
+ - `Guzzle\Http\EntityBodyInterface` is now `GuzzleHttp\Stream\StreamInterface`
489
+ - `Guzzle\Http\EntityBody` is now `GuzzleHttp\Stream\Stream`
490
+ - `Guzzle\Http\CachingEntityBody` is now `GuzzleHttp\Stream\CachingStream`
491
+ - `Guzzle\Http\ReadLimitEntityBody` is now `GuzzleHttp\Stream\LimitStream`
492
+ - `Guzzle\Http\IoEmittyinEntityBody` has been removed.
493
+
494
+ #### Request lifecycle events
495
+
496
+ Requests previously submitted a large number of requests. The number of events
497
+ emitted over the lifecycle of a request has been significantly reduced to make
498
+ it easier to understand how to extend the behavior of a request. All events
499
+ emitted during the lifecycle of a request now emit a custom
500
+ `GuzzleHttp\Event\EventInterface` object that contains context providing
501
+ methods and a way in which to modify the transaction at that specific point in
502
+ time (e.g., intercept the request and set a response on the transaction).
503
+
504
+ - `request.before_send` has been renamed to `before` and now emits a
505
+ `GuzzleHttp\Event\BeforeEvent`
506
+ - `request.complete` has been renamed to `complete` and now emits a
507
+ `GuzzleHttp\Event\CompleteEvent`.
508
+ - `request.sent` has been removed. Use `complete`.
509
+ - `request.success` has been removed. Use `complete`.
510
+ - `error` is now an event that emits a `GuzzleHttp\Event\ErrorEvent`.
511
+ - `request.exception` has been removed. Use `error`.
512
+ - `request.receive.status_line` has been removed.
513
+ - `curl.callback.progress` has been removed. Use a custom `StreamInterface` to
514
+ maintain a status update.
515
+ - `curl.callback.write` has been removed. Use a custom `StreamInterface` to
516
+ intercept writes.
517
+ - `curl.callback.read` has been removed. Use a custom `StreamInterface` to
518
+ intercept reads.
519
+
520
+ `headers` is a new event that is emitted after the response headers of a
521
+ request have been received before the body of the response is downloaded. This
522
+ event emits a `GuzzleHttp\Event\HeadersEvent`.
523
+
524
+ You can intercept a request and inject a response using the `intercept()` event
525
+ of a `GuzzleHttp\Event\BeforeEvent`, `GuzzleHttp\Event\CompleteEvent`, and
526
+ `GuzzleHttp\Event\ErrorEvent` event.
527
+
528
+ See: http://docs.guzzlephp.org/en/latest/events.html
529
+
530
+ ## Inflection
531
+
532
+ The `Guzzle\Inflection` namespace has been removed. This is not a core concern
533
+ of Guzzle.
534
+
535
+ ## Iterator
536
+
537
+ The `Guzzle\Iterator` namespace has been removed.
538
+
539
+ - `Guzzle\Iterator\AppendIterator`, `Guzzle\Iterator\ChunkedIterator`, and
540
+ `Guzzle\Iterator\MethodProxyIterator` are nice, but not a core requirement of
541
+ Guzzle itself.
542
+ - `Guzzle\Iterator\FilterIterator` is no longer needed because an equivalent
543
+ class is shipped with PHP 5.4.
544
+ - `Guzzle\Iterator\MapIterator` is not really needed when using PHP 5.5 because
545
+ it's easier to just wrap an iterator in a generator that maps values.
546
+
547
+ For a replacement of these iterators, see https://github.com/nikic/iter
548
+
549
+ ## Log
550
+
551
+ The LogPlugin has moved to https://github.com/guzzle/log-subscriber. The
552
+ `Guzzle\Log` namespace has been removed. Guzzle now relies on
553
+ `Psr\Log\LoggerInterface` for all logging. The MessageFormatter class has been
554
+ moved to `GuzzleHttp\Subscriber\Log\Formatter`.
555
+
556
+ ## Parser
557
+
558
+ The `Guzzle\Parser` namespace has been removed. This was previously used to
559
+ make it possible to plug in custom parsers for cookies, messages, URI
560
+ templates, and URLs; however, this level of complexity is not needed in Guzzle
561
+ so it has been removed.
562
+
563
+ - Cookie: Cookie parsing logic has been moved to
564
+ `GuzzleHttp\Cookie\SetCookie::fromString`.
565
+ - Message: Message parsing logic for both requests and responses has been moved
566
+ to `GuzzleHttp\Message\MessageFactory::fromMessage`. Message parsing is only
567
+ used in debugging or deserializing messages, so it doesn't make sense for
568
+ Guzzle as a library to add this level of complexity to parsing messages.
569
+ - UriTemplate: URI template parsing has been moved to
570
+ `GuzzleHttp\UriTemplate`. The Guzzle library will automatically use the PECL
571
+ URI template library if it is installed.
572
+ - Url: URL parsing is now performed in `GuzzleHttp\Url::fromString` (previously
573
+ it was `Guzzle\Http\Url::factory()`). If custom URL parsing is necessary,
574
+ then developers are free to subclass `GuzzleHttp\Url`.
575
+
576
+ ## Plugin
577
+
578
+ The `Guzzle\Plugin` namespace has been renamed to `GuzzleHttp\Subscriber`.
579
+ Several plugins are shipping with the core Guzzle library under this namespace.
580
+
581
+ - `GuzzleHttp\Subscriber\Cookie`: Replaces the old CookiePlugin. Cookie jar
582
+ code has moved to `GuzzleHttp\Cookie`.
583
+ - `GuzzleHttp\Subscriber\History`: Replaces the old HistoryPlugin.
584
+ - `GuzzleHttp\Subscriber\HttpError`: Throws errors when a bad HTTP response is
585
+ received.
586
+ - `GuzzleHttp\Subscriber\Mock`: Replaces the old MockPlugin.
587
+ - `GuzzleHttp\Subscriber\Prepare`: Prepares the body of a request just before
588
+ sending. This subscriber is attached to all requests by default.
589
+ - `GuzzleHttp\Subscriber\Redirect`: Replaces the RedirectPlugin.
590
+
591
+ The following plugins have been removed (third-parties are free to re-implement
592
+ these if needed):
593
+
594
+ - `GuzzleHttp\Plugin\Async` has been removed.
595
+ - `GuzzleHttp\Plugin\CurlAuth` has been removed.
596
+ - `GuzzleHttp\Plugin\ErrorResponse\ErrorResponsePlugin` has been removed. This
597
+ functionality should instead be implemented with event listeners that occur
598
+ after normal response parsing occurs in the guzzle/command package.
599
+
600
+ The following plugins are not part of the core Guzzle package, but are provided
601
+ in separate repositories:
602
+
603
+ - `Guzzle\Http\Plugin\BackoffPlugin` has been rewritten to be muchs simpler
604
+ to build custom retry policies using simple functions rather than various
605
+ chained classes. See: https://github.com/guzzle/retry-subscriber
606
+ - `Guzzle\Http\Plugin\Cache\CachePlugin` has moved to
607
+ https://github.com/guzzle/cache-subscriber
608
+ - `Guzzle\Http\Plugin\Log\LogPlugin` has moved to
609
+ https://github.com/guzzle/log-subscriber
610
+ - `Guzzle\Http\Plugin\Md5\Md5Plugin` has moved to
611
+ https://github.com/guzzle/message-integrity-subscriber
612
+ - `Guzzle\Http\Plugin\Mock\MockPlugin` has moved to
613
+ `GuzzleHttp\Subscriber\MockSubscriber`.
614
+ - `Guzzle\Http\Plugin\Oauth\OauthPlugin` has moved to
615
+ https://github.com/guzzle/oauth-subscriber
616
+
617
+ ## Service
618
+
619
+ The service description layer of Guzzle has moved into two separate packages:
620
+
621
+ - http://github.com/guzzle/command Provides a high level abstraction over web
622
+ services by representing web service operations using commands.
623
+ - http://github.com/guzzle/guzzle-services Provides an implementation of
624
+ guzzle/command that provides request serialization and response parsing using
625
+ Guzzle service descriptions.
626
+
627
+ ## Stream
628
+
629
+ Stream have moved to a separate package available at
630
+ https://github.com/guzzle/streams.
631
+
632
+ `Guzzle\Stream\StreamInterface` has been given a large update to cleanly take
633
+ on the responsibilities of `Guzzle\Http\EntityBody` and
634
+ `Guzzle\Http\EntityBodyInterface` now that they have been removed. The number
635
+ of methods implemented by the `StreamInterface` has been drastically reduced to
636
+ allow developers to more easily extend and decorate stream behavior.
637
+
638
+ ## Removed methods from StreamInterface
639
+
640
+ - `getStream` and `setStream` have been removed to better encapsulate streams.
641
+ - `getMetadata` and `setMetadata` have been removed in favor of
642
+ `GuzzleHttp\Stream\MetadataStreamInterface`.
643
+ - `getWrapper`, `getWrapperData`, `getStreamType`, and `getUri` have all been
644
+ removed. This data is accessible when
645
+ using streams that implement `GuzzleHttp\Stream\MetadataStreamInterface`.
646
+ - `rewind` has been removed. Use `seek(0)` for a similar behavior.
647
+
648
+ ## Renamed methods
649
+
650
+ - `detachStream` has been renamed to `detach`.
651
+ - `feof` has been renamed to `eof`.
652
+ - `ftell` has been renamed to `tell`.
653
+ - `readLine` has moved from an instance method to a static class method of
654
+ `GuzzleHttp\Stream\Stream`.
655
+
656
+ ## Metadata streams
657
+
658
+ `GuzzleHttp\Stream\MetadataStreamInterface` has been added to denote streams
659
+ that contain additional metadata accessible via `getMetadata()`.
660
+ `GuzzleHttp\Stream\StreamInterface::getMetadata` and
661
+ `GuzzleHttp\Stream\StreamInterface::setMetadata` have been removed.
662
+
663
+ ## StreamRequestFactory
664
+
665
+ The entire concept of the StreamRequestFactory has been removed. The way this
666
+ was used in Guzzle 3 broke the actual interface of sending streaming requests
667
+ (instead of getting back a Response, you got a StreamInterface). Streeaming
668
+ PHP requests are now implemented throught the `GuzzleHttp\Adapter\StreamAdapter`.
669
+
670
+ 3.6 to 3.7
671
+ ----------
672
+
673
+ ### Deprecations
674
+
675
+ - You can now enable E_USER_DEPRECATED warnings to see if you are using any deprecated methods.:
676
+
677
+ ```php
678
+ \Guzzle\Common\Version::$emitWarnings = true;
679
+ ```
680
+
681
+ The following APIs and options have been marked as deprecated:
682
+
683
+ - Marked `Guzzle\Http\Message\Request::isResponseBodyRepeatable()` as deprecated. Use `$request->getResponseBody()->isRepeatable()` instead.
684
+ - Marked `Guzzle\Http\Message\Request::canCache()` as deprecated. Use `Guzzle\Plugin\Cache\DefaultCanCacheStrategy->canCacheRequest()` instead.
685
+ - Marked `Guzzle\Http\Message\Request::canCache()` as deprecated. Use `Guzzle\Plugin\Cache\DefaultCanCacheStrategy->canCacheRequest()` instead.
686
+ - Marked `Guzzle\Http\Message\Request::setIsRedirect()` as deprecated. Use the HistoryPlugin instead.
687
+ - Marked `Guzzle\Http\Message\Request::isRedirect()` as deprecated. Use the HistoryPlugin instead.
688
+ - Marked `Guzzle\Cache\CacheAdapterFactory::factory()` as deprecated
689
+ - Marked `Guzzle\Service\Client::enableMagicMethods()` as deprecated. Magic methods can no longer be disabled on a Guzzle\Service\Client.
690
+ - Marked `Guzzle\Parser\Url\UrlParser` as deprecated. Just use PHP's `parse_url()` and percent encode your UTF-8.
691
+ - Marked `Guzzle\Common\Collection::inject()` as deprecated.
692
+ - Marked `Guzzle\Plugin\CurlAuth\CurlAuthPlugin` as deprecated. Use
693
+ `$client->getConfig()->setPath('request.options/auth', array('user', 'pass', 'Basic|Digest|NTLM|Any'));` or
694
+ `$client->setDefaultOption('auth', array('user', 'pass', 'Basic|Digest|NTLM|Any'));`
695
+
696
+ 3.7 introduces `request.options` as a parameter for a client configuration and as an optional argument to all creational
697
+ request methods. When paired with a client's configuration settings, these options allow you to specify default settings
698
+ for various aspects of a request. Because these options make other previous configuration options redundant, several
699
+ configuration options and methods of a client and AbstractCommand have been deprecated.
700
+
701
+ - Marked `Guzzle\Service\Client::getDefaultHeaders()` as deprecated. Use `$client->getDefaultOption('headers')`.
702
+ - Marked `Guzzle\Service\Client::setDefaultHeaders()` as deprecated. Use `$client->setDefaultOption('headers/{header_name}', 'value')`.
703
+ - Marked 'request.params' for `Guzzle\Http\Client` as deprecated. Use `$client->setDefaultOption('params/{param_name}', 'value')`
704
+ - Marked 'command.headers', 'command.response_body' and 'command.on_complete' as deprecated for AbstractCommand. These will work through Guzzle 4.0
705
+
706
+ $command = $client->getCommand('foo', array(
707
+ 'command.headers' => array('Test' => '123'),
708
+ 'command.response_body' => '/path/to/file'
709
+ ));
710
+
711
+ // Should be changed to:
712
+
713
+ $command = $client->getCommand('foo', array(
714
+ 'command.request_options' => array(
715
+ 'headers' => array('Test' => '123'),
716
+ 'save_as' => '/path/to/file'
717
+ )
718
+ ));
719
+
720
+ ### Interface changes
721
+
722
+ Additions and changes (you will need to update any implementations or subclasses you may have created):
723
+
724
+ - Added an `$options` argument to the end of the following methods of `Guzzle\Http\ClientInterface`:
725
+ createRequest, head, delete, put, patch, post, options, prepareRequest
726
+ - Added an `$options` argument to the end of `Guzzle\Http\Message\Request\RequestFactoryInterface::createRequest()`
727
+ - Added an `applyOptions()` method to `Guzzle\Http\Message\Request\RequestFactoryInterface`
728
+ - Changed `Guzzle\Http\ClientInterface::get($uri = null, $headers = null, $body = null)` to
729
+ `Guzzle\Http\ClientInterface::get($uri = null, $headers = null, $options = array())`. You can still pass in a
730
+ resource, string, or EntityBody into the $options parameter to specify the download location of the response.
731
+ - Changed `Guzzle\Common\Collection::__construct($data)` to no longer accepts a null value for `$data` but a
732
+ default `array()`
733
+ - Added `Guzzle\Stream\StreamInterface::isRepeatable`
734
+ - Made `Guzzle\Http\Client::expandTemplate` and `getUriTemplate` protected methods.
735
+
736
+ The following methods were removed from interfaces. All of these methods are still available in the concrete classes
737
+ that implement them, but you should update your code to use alternative methods:
738
+
739
+ - Removed `Guzzle\Http\ClientInterface::setDefaultHeaders(). Use
740
+ `$client->getConfig()->setPath('request.options/headers/{header_name}', 'value')`. or
741
+ `$client->getConfig()->setPath('request.options/headers', array('header_name' => 'value'))` or
742
+ `$client->setDefaultOption('headers/{header_name}', 'value')`. or
743
+ `$client->setDefaultOption('headers', array('header_name' => 'value'))`.
744
+ - Removed `Guzzle\Http\ClientInterface::getDefaultHeaders(). Use `$client->getConfig()->getPath('request.options/headers')`.
745
+ - Removed `Guzzle\Http\ClientInterface::expandTemplate()`. This is an implementation detail.
746
+ - Removed `Guzzle\Http\ClientInterface::setRequestFactory()`. This is an implementation detail.
747
+ - Removed `Guzzle\Http\ClientInterface::getCurlMulti()`. This is a very specific implementation detail.
748
+ - Removed `Guzzle\Http\Message\RequestInterface::canCache`. Use the CachePlugin.
749
+ - Removed `Guzzle\Http\Message\RequestInterface::setIsRedirect`. Use the HistoryPlugin.
750
+ - Removed `Guzzle\Http\Message\RequestInterface::isRedirect`. Use the HistoryPlugin.
751
+
752
+ ### Cache plugin breaking changes
753
+
754
+ - CacheKeyProviderInterface and DefaultCacheKeyProvider are no longer used. All of this logic is handled in a
755
+ CacheStorageInterface. These two objects and interface will be removed in a future version.
756
+ - Always setting X-cache headers on cached responses
757
+ - Default cache TTLs are now handled by the CacheStorageInterface of a CachePlugin
758
+ - `CacheStorageInterface::cache($key, Response $response, $ttl = null)` has changed to `cache(RequestInterface
759
+ $request, Response $response);`
760
+ - `CacheStorageInterface::fetch($key)` has changed to `fetch(RequestInterface $request);`
761
+ - `CacheStorageInterface::delete($key)` has changed to `delete(RequestInterface $request);`
762
+ - Added `CacheStorageInterface::purge($url)`
763
+ - `DefaultRevalidation::__construct(CacheKeyProviderInterface $cacheKey, CacheStorageInterface $cache, CachePlugin
764
+ $plugin)` has changed to `DefaultRevalidation::__construct(CacheStorageInterface $cache,
765
+ CanCacheStrategyInterface $canCache = null)`
766
+ - Added `RevalidationInterface::shouldRevalidate(RequestInterface $request, Response $response)`
767
+
768
+ 3.5 to 3.6
769
+ ----------
770
+
771
+ * Mixed casing of headers are now forced to be a single consistent casing across all values for that header.
772
+ * Messages internally use a HeaderCollection object to delegate handling case-insensitive header resolution
773
+ * Removed the whole changedHeader() function system of messages because all header changes now go through addHeader().
774
+ For example, setHeader() first removes the header using unset on a HeaderCollection and then calls addHeader().
775
+ Keeping the Host header and URL host in sync is now handled by overriding the addHeader method in Request.
776
+ * Specific header implementations can be created for complex headers. When a message creates a header, it uses a
777
+ HeaderFactory which can map specific headers to specific header classes. There is now a Link header and
778
+ CacheControl header implementation.
779
+ * Moved getLinks() from Response to just be used on a Link header object.
780
+
781
+ If you previously relied on Guzzle\Http\Message\Header::raw(), then you will need to update your code to use the
782
+ HeaderInterface (e.g. toArray(), getAll(), etc.).
783
+
784
+ ### Interface changes
785
+
786
+ * Removed from interface: Guzzle\Http\ClientInterface::setUriTemplate
787
+ * Removed from interface: Guzzle\Http\ClientInterface::setCurlMulti()
788
+ * Removed Guzzle\Http\Message\Request::receivedRequestHeader() and implemented this functionality in
789
+ Guzzle\Http\Curl\RequestMediator
790
+ * Removed the optional $asString parameter from MessageInterface::getHeader(). Just cast the header to a string.
791
+ * Removed the optional $tryChunkedTransfer option from Guzzle\Http\Message\EntityEnclosingRequestInterface
792
+ * Removed the $asObjects argument from Guzzle\Http\Message\MessageInterface::getHeaders()
793
+
794
+ ### Removed deprecated functions
795
+
796
+ * Removed Guzzle\Parser\ParserRegister::get(). Use getParser()
797
+ * Removed Guzzle\Parser\ParserRegister::set(). Use registerParser().
798
+
799
+ ### Deprecations
800
+
801
+ * The ability to case-insensitively search for header values
802
+ * Guzzle\Http\Message\Header::hasExactHeader
803
+ * Guzzle\Http\Message\Header::raw. Use getAll()
804
+ * Deprecated cache control specific methods on Guzzle\Http\Message\AbstractMessage. Use the CacheControl header object
805
+ instead.
806
+
807
+ ### Other changes
808
+
809
+ * All response header helper functions return a string rather than mixing Header objects and strings inconsistently
810
+ * Removed cURL blacklist support. This is no longer necessary now that Expect, Accept, etc. are managed by Guzzle
811
+ directly via interfaces
812
+ * Removed the injecting of a request object onto a response object. The methods to get and set a request still exist
813
+ but are a no-op until removed.
814
+ * Most classes that used to require a `Guzzle\Service\Command\CommandInterface` typehint now request a
815
+ `Guzzle\Service\Command\ArrayCommandInterface`.
816
+ * Added `Guzzle\Http\Message\RequestInterface::startResponse()` to the RequestInterface to handle injecting a response
817
+ on a request while the request is still being transferred
818
+ * `Guzzle\Service\Command\CommandInterface` now extends from ToArrayInterface and ArrayAccess
819
+
820
+ 3.3 to 3.4
821
+ ----------
822
+
823
+ Base URLs of a client now follow the rules of http://tools.ietf.org/html/rfc3986#section-5.2.2 when merging URLs.
824
+
825
+ 3.2 to 3.3
826
+ ----------
827
+
828
+ ### Response::getEtag() quote stripping removed
829
+
830
+ `Guzzle\Http\Message\Response::getEtag()` no longer strips quotes around the ETag response header
831
+
832
+ ### Removed `Guzzle\Http\Utils`
833
+
834
+ The `Guzzle\Http\Utils` class was removed. This class was only used for testing.
835
+
836
+ ### Stream wrapper and type
837
+
838
+ `Guzzle\Stream\Stream::getWrapper()` and `Guzzle\Stream\Stream::getStreamType()` are no longer converted to lowercase.
839
+
840
+ ### curl.emit_io became emit_io
841
+
842
+ Emitting IO events from a RequestMediator is now a parameter that must be set in a request's curl options using the
843
+ 'emit_io' key. This was previously set under a request's parameters using 'curl.emit_io'
844
+
845
+ 3.1 to 3.2
846
+ ----------
847
+
848
+ ### CurlMulti is no longer reused globally
849
+
850
+ Before 3.2, the same CurlMulti object was reused globally for each client. This can cause issue where plugins added
851
+ to a single client can pollute requests dispatched from other clients.
852
+
853
+ If you still wish to reuse the same CurlMulti object with each client, then you can add a listener to the
854
+ ServiceBuilder's `service_builder.create_client` event to inject a custom CurlMulti object into each client as it is
855
+ created.
856
+
857
+ ```php
858
+ $multi = new Guzzle\Http\Curl\CurlMulti();
859
+ $builder = Guzzle\Service\Builder\ServiceBuilder::factory('/path/to/config.json');
860
+ $builder->addListener('service_builder.create_client', function ($event) use ($multi) {
861
+ $event['client']->setCurlMulti($multi);
862
+ }
863
+ });
864
+ ```
865
+
866
+ ### No default path
867
+
868
+ URLs no longer have a default path value of '/' if no path was specified.
869
+
870
+ Before:
871
+
872
+ ```php
873
+ $request = $client->get('http://www.foo.com');
874
+ echo $request->getUrl();
875
+ // >> http://www.foo.com/
876
+ ```
877
+
878
+ After:
879
+
880
+ ```php
881
+ $request = $client->get('http://www.foo.com');
882
+ echo $request->getUrl();
883
+ // >> http://www.foo.com
884
+ ```
885
+
886
+ ### Less verbose BadResponseException
887
+
888
+ The exception message for `Guzzle\Http\Exception\BadResponseException` no longer contains the full HTTP request and
889
+ response information. You can, however, get access to the request and response object by calling `getRequest()` or
890
+ `getResponse()` on the exception object.
891
+
892
+ ### Query parameter aggregation
893
+
894
+ Multi-valued query parameters are no longer aggregated using a callback function. `Guzzle\Http\Query` now has a
895
+ setAggregator() method that accepts a `Guzzle\Http\QueryAggregator\QueryAggregatorInterface` object. This object is
896
+ responsible for handling the aggregation of multi-valued query string variables into a flattened hash.
897
+
898
+ 2.8 to 3.x
899
+ ----------
900
+
901
+ ### Guzzle\Service\Inspector
902
+
903
+ Change `\Guzzle\Service\Inspector::fromConfig` to `\Guzzle\Common\Collection::fromConfig`
904
+
905
+ **Before**
906
+
907
+ ```php
908
+ use Guzzle\Service\Inspector;
909
+
910
+ class YourClient extends \Guzzle\Service\Client
911
+ {
912
+ public static function factory($config = array())
913
+ {
914
+ $default = array();
915
+ $required = array('base_url', 'username', 'api_key');
916
+ $config = Inspector::fromConfig($config, $default, $required);
917
+
918
+ $client = new self(
919
+ $config->get('base_url'),
920
+ $config->get('username'),
921
+ $config->get('api_key')
922
+ );
923
+ $client->setConfig($config);
924
+
925
+ $client->setDescription(ServiceDescription::factory(__DIR__ . DIRECTORY_SEPARATOR . 'client.json'));
926
+
927
+ return $client;
928
+ }
929
+ ```
930
+
931
+ **After**
932
+
933
+ ```php
934
+ use Guzzle\Common\Collection;
935
+
936
+ class YourClient extends \Guzzle\Service\Client
937
+ {
938
+ public static function factory($config = array())
939
+ {
940
+ $default = array();
941
+ $required = array('base_url', 'username', 'api_key');
942
+ $config = Collection::fromConfig($config, $default, $required);
943
+
944
+ $client = new self(
945
+ $config->get('base_url'),
946
+ $config->get('username'),
947
+ $config->get('api_key')
948
+ );
949
+ $client->setConfig($config);
950
+
951
+ $client->setDescription(ServiceDescription::factory(__DIR__ . DIRECTORY_SEPARATOR . 'client.json'));
952
+
953
+ return $client;
954
+ }
955
+ ```
956
+
957
+ ### Convert XML Service Descriptions to JSON
958
+
959
+ **Before**
960
+
961
+ ```xml
962
+ <?xml version="1.0" encoding="UTF-8"?>
963
+ <client>
964
+ <commands>
965
+ <!-- Groups -->
966
+ <command name="list_groups" method="GET" uri="groups.json">
967
+ <doc>Get a list of groups</doc>
968
+ </command>
969
+ <command name="search_groups" method="GET" uri='search.json?query="{{query}} type:group"'>
970
+ <doc>Uses a search query to get a list of groups</doc>
971
+ <param name="query" type="string" required="true" />
972
+ </command>
973
+ <command name="create_group" method="POST" uri="groups.json">
974
+ <doc>Create a group</doc>
975
+ <param name="data" type="array" location="body" filters="json_encode" doc="Group JSON"/>
976
+ <param name="Content-Type" location="header" static="application/json"/>
977
+ </command>
978
+ <command name="delete_group" method="DELETE" uri="groups/{{id}}.json">
979
+ <doc>Delete a group by ID</doc>
980
+ <param name="id" type="integer" required="true"/>
981
+ </command>
982
+ <command name="get_group" method="GET" uri="groups/{{id}}.json">
983
+ <param name="id" type="integer" required="true"/>
984
+ </command>
985
+ <command name="update_group" method="PUT" uri="groups/{{id}}.json">
986
+ <doc>Update a group</doc>
987
+ <param name="id" type="integer" required="true"/>
988
+ <param name="data" type="array" location="body" filters="json_encode" doc="Group JSON"/>
989
+ <param name="Content-Type" location="header" static="application/json"/>
990
+ </command>
991
+ </commands>
992
+ </client>
993
+ ```
994
+
995
+ **After**
996
+
997
+ ```json
998
+ {
999
+ "name": "Zendesk REST API v2",
1000
+ "apiVersion": "2012-12-31",
1001
+ "description":"Provides access to Zendesk views, groups, tickets, ticket fields, and users",
1002
+ "operations": {
1003
+ "list_groups": {
1004
+ "httpMethod":"GET",
1005
+ "uri": "groups.json",
1006
+ "summary": "Get a list of groups"
1007
+ },
1008
+ "search_groups":{
1009
+ "httpMethod":"GET",
1010
+ "uri": "search.json?query=\"{query} type:group\"",
1011
+ "summary": "Uses a search query to get a list of groups",
1012
+ "parameters":{
1013
+ "query":{
1014
+ "location": "uri",
1015
+ "description":"Zendesk Search Query",
1016
+ "type": "string",
1017
+ "required": true
1018
+ }
1019
+ }
1020
+ },
1021
+ "create_group": {
1022
+ "httpMethod":"POST",
1023
+ "uri": "groups.json",
1024
+ "summary": "Create a group",
1025
+ "parameters":{
1026
+ "data": {
1027
+ "type": "array",
1028
+ "location": "body",
1029
+ "description":"Group JSON",
1030
+ "filters": "json_encode",
1031
+ "required": true
1032
+ },
1033
+ "Content-Type":{
1034
+ "type": "string",
1035
+ "location":"header",
1036
+ "static": "application/json"
1037
+ }
1038
+ }
1039
+ },
1040
+ "delete_group": {
1041
+ "httpMethod":"DELETE",
1042
+ "uri": "groups/{id}.json",
1043
+ "summary": "Delete a group",
1044
+ "parameters":{
1045
+ "id":{
1046
+ "location": "uri",
1047
+ "description":"Group to delete by ID",
1048
+ "type": "integer",
1049
+ "required": true
1050
+ }
1051
+ }
1052
+ },
1053
+ "get_group": {
1054
+ "httpMethod":"GET",
1055
+ "uri": "groups/{id}.json",
1056
+ "summary": "Get a ticket",
1057
+ "parameters":{
1058
+ "id":{
1059
+ "location": "uri",
1060
+ "description":"Group to get by ID",
1061
+ "type": "integer",
1062
+ "required": true
1063
+ }
1064
+ }
1065
+ },
1066
+ "update_group": {
1067
+ "httpMethod":"PUT",
1068
+ "uri": "groups/{id}.json",
1069
+ "summary": "Update a group",
1070
+ "parameters":{
1071
+ "id": {
1072
+ "location": "uri",
1073
+ "description":"Group to update by ID",
1074
+ "type": "integer",
1075
+ "required": true
1076
+ },
1077
+ "data": {
1078
+ "type": "array",
1079
+ "location": "body",
1080
+ "description":"Group JSON",
1081
+ "filters": "json_encode",
1082
+ "required": true
1083
+ },
1084
+ "Content-Type":{
1085
+ "type": "string",
1086
+ "location":"header",
1087
+ "static": "application/json"
1088
+ }
1089
+ }
1090
+ }
1091
+ }
1092
+ ```
1093
+
1094
+ ### Guzzle\Service\Description\ServiceDescription
1095
+
1096
+ Commands are now called Operations
1097
+
1098
+ **Before**
1099
+
1100
+ ```php
1101
+ use Guzzle\Service\Description\ServiceDescription;
1102
+
1103
+ $sd = new ServiceDescription();
1104
+ $sd->getCommands(); // @returns ApiCommandInterface[]
1105
+ $sd->hasCommand($name);
1106
+ $sd->getCommand($name); // @returns ApiCommandInterface|null
1107
+ $sd->addCommand($command); // @param ApiCommandInterface $command
1108
+ ```
1109
+
1110
+ **After**
1111
+
1112
+ ```php
1113
+ use Guzzle\Service\Description\ServiceDescription;
1114
+
1115
+ $sd = new ServiceDescription();
1116
+ $sd->getOperations(); // @returns OperationInterface[]
1117
+ $sd->hasOperation($name);
1118
+ $sd->getOperation($name); // @returns OperationInterface|null
1119
+ $sd->addOperation($operation); // @param OperationInterface $operation
1120
+ ```
1121
+
1122
+ ### Guzzle\Common\Inflection\Inflector
1123
+
1124
+ Namespace is now `Guzzle\Inflection\Inflector`
1125
+
1126
+ ### Guzzle\Http\Plugin
1127
+
1128
+ Namespace is now `Guzzle\Plugin`. Many other changes occur within this namespace and are detailed in their own sections below.
1129
+
1130
+ ### Guzzle\Http\Plugin\LogPlugin and Guzzle\Common\Log
1131
+
1132
+ Now `Guzzle\Plugin\Log\LogPlugin` and `Guzzle\Log` respectively.
1133
+
1134
+ **Before**
1135
+
1136
+ ```php
1137
+ use Guzzle\Common\Log\ClosureLogAdapter;
1138
+ use Guzzle\Http\Plugin\LogPlugin;
1139
+
1140
+ /** @var \Guzzle\Http\Client */
1141
+ $client;
1142
+
1143
+ // $verbosity is an integer indicating desired message verbosity level
1144
+ $client->addSubscriber(new LogPlugin(new ClosureLogAdapter(function($m) { echo $m; }, $verbosity = LogPlugin::LOG_VERBOSE);
1145
+ ```
1146
+
1147
+ **After**
1148
+
1149
+ ```php
1150
+ use Guzzle\Log\ClosureLogAdapter;
1151
+ use Guzzle\Log\MessageFormatter;
1152
+ use Guzzle\Plugin\Log\LogPlugin;
1153
+
1154
+ /** @var \Guzzle\Http\Client */
1155
+ $client;
1156
+
1157
+ // $format is a string indicating desired message format -- @see MessageFormatter
1158
+ $client->addSubscriber(new LogPlugin(new ClosureLogAdapter(function($m) { echo $m; }, $format = MessageFormatter::DEBUG_FORMAT);
1159
+ ```
1160
+
1161
+ ### Guzzle\Http\Plugin\CurlAuthPlugin
1162
+
1163
+ Now `Guzzle\Plugin\CurlAuth\CurlAuthPlugin`.
1164
+
1165
+ ### Guzzle\Http\Plugin\ExponentialBackoffPlugin
1166
+
1167
+ Now `Guzzle\Plugin\Backoff\BackoffPlugin`, and other changes.
1168
+
1169
+ **Before**
1170
+
1171
+ ```php
1172
+ use Guzzle\Http\Plugin\ExponentialBackoffPlugin;
1173
+
1174
+ $backoffPlugin = new ExponentialBackoffPlugin($maxRetries, array_merge(
1175
+ ExponentialBackoffPlugin::getDefaultFailureCodes(), array(429)
1176
+ ));
1177
+
1178
+ $client->addSubscriber($backoffPlugin);
1179
+ ```
1180
+
1181
+ **After**
1182
+
1183
+ ```php
1184
+ use Guzzle\Plugin\Backoff\BackoffPlugin;
1185
+ use Guzzle\Plugin\Backoff\HttpBackoffStrategy;
1186
+
1187
+ // Use convenient factory method instead -- see implementation for ideas of what
1188
+ // you can do with chaining backoff strategies
1189
+ $backoffPlugin = BackoffPlugin::getExponentialBackoff($maxRetries, array_merge(
1190
+ HttpBackoffStrategy::getDefaultFailureCodes(), array(429)
1191
+ ));
1192
+ $client->addSubscriber($backoffPlugin);
1193
+ ```
1194
+
1195
+ ### Known Issues
1196
+
1197
+ #### [BUG] Accept-Encoding header behavior changed unintentionally.
1198
+
1199
+ (See #217) (Fixed in 09daeb8c666fb44499a0646d655a8ae36456575e)
1200
+
1201
+ In version 2.8 setting the `Accept-Encoding` header would set the CURLOPT_ENCODING option, which permitted cURL to
1202
+ properly handle gzip/deflate compressed responses from the server. In versions affected by this bug this does not happen.
1203
+ See issue #217 for a workaround, or use a version containing the fix.
app/api/Ctct/vendor/guzzlehttp/guzzle/composer.json ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "guzzlehttp/guzzle",
3
+ "type": "library",
4
+ "description": "Guzzle is a PHP HTTP client library",
5
+ "keywords": ["framework", "http", "rest", "web service", "curl", "client", "HTTP client"],
6
+ "homepage": "http://guzzlephp.org/",
7
+ "license": "MIT",
8
+ "authors": [
9
+ {
10
+ "name": "Michael Dowling",
11
+ "email": "mtdowling@gmail.com",
12
+ "homepage": "https://github.com/mtdowling"
13
+ }
14
+ ],
15
+ "require": {
16
+ "php": ">=5.5.0",
17
+ "guzzlehttp/psr7": "~1.1",
18
+ "guzzlehttp/promises": "~1.0"
19
+ },
20
+ "require-dev": {
21
+ "ext-curl": "*",
22
+ "phpunit/phpunit": "~4.0",
23
+ "psr/log": "~1.0"
24
+ },
25
+ "autoload": {
26
+ "files": ["src/functions_include.php"],
27
+ "psr-4": {
28
+ "GuzzleHttp\\": "src/"
29
+ }
30
+ },
31
+ "autoload-dev": {
32
+ "psr-4": {
33
+ "GuzzleHttp\\Tests\\": "tests/"
34
+ }
35
+ },
36
+ "extra": {
37
+ "branch-alias": {
38
+ "dev-master": "6.1-dev"
39
+ }
40
+ }
41
+ }
app/api/Ctct/vendor/guzzlehttp/guzzle/src/Client.php ADDED
@@ -0,0 +1,397 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp;
3
+
4
+ use GuzzleHttp\Cookie\CookieJar;
5
+ use GuzzleHttp\Promise;
6
+ use GuzzleHttp\Psr7;
7
+ use Psr\Http\Message\UriInterface;
8
+ use Psr\Http\Message\RequestInterface;
9
+ use Psr\Http\Message\ResponseInterface;
10
+
11
+ /**
12
+ * @method ResponseInterface get($uri, array $options = [])
13
+ * @method ResponseInterface head($uri, array $options = [])
14
+ * @method ResponseInterface put($uri, array $options = [])
15
+ * @method ResponseInterface post($uri, array $options = [])
16
+ * @method ResponseInterface patch($uri, array $options = [])
17
+ * @method ResponseInterface delete($uri, array $options = [])
18
+ * @method Promise\PromiseInterface getAsync($uri, array $options = [])
19
+ * @method Promise\PromiseInterface headAsync($uri, array $options = [])
20
+ * @method Promise\PromiseInterface putAsync($uri, array $options = [])
21
+ * @method Promise\PromiseInterface postAsync($uri, array $options = [])
22
+ * @method Promise\PromiseInterface patchAsync($uri, array $options = [])
23
+ * @method Promise\PromiseInterface deleteAsync($uri, array $options = [])
24
+ */
25
+ class Client implements ClientInterface
26
+ {
27
+ /** @var array Default request options */
28
+ private $config;
29
+
30
+ /**
31
+ * Clients accept an array of constructor parameters.
32
+ *
33
+ * Here's an example of creating a client using a base_uri and an array of
34
+ * default request options to apply to each request:
35
+ *
36
+ * $client = new Client([
37
+ * 'base_uri' => 'http://www.foo.com/1.0/',
38
+ * 'timeout' => 0,
39
+ * 'allow_redirects' => false,
40
+ * 'proxy' => '192.168.16.1:10'
41
+ * ]);
42
+ *
43
+ * Client configuration settings include the following options:
44
+ *
45
+ * - handler: (callable) Function that transfers HTTP requests over the
46
+ * wire. The function is called with a Psr7\Http\Message\RequestInterface
47
+ * and array of transfer options, and must return a
48
+ * GuzzleHttp\Promise\PromiseInterface that is fulfilled with a
49
+ * Psr7\Http\Message\ResponseInterface on success. "handler" is a
50
+ * constructor only option that cannot be overridden in per/request
51
+ * options. If no handler is provided, a default handler will be created
52
+ * that enables all of the request options below by attaching all of the
53
+ * default middleware to the handler.
54
+ * - base_uri: (string|UriInterface) Base URI of the client that is merged
55
+ * into relative URIs. Can be a string or instance of UriInterface.
56
+ * - **: any request option
57
+ *
58
+ * @param array $config Client configuration settings.
59
+ *
60
+ * @see \GuzzleHttp\RequestOptions for a list of available request options.
61
+ */
62
+ public function __construct(array $config = [])
63
+ {
64
+ if (!isset($config['handler'])) {
65
+ $config['handler'] = HandlerStack::create();
66
+ }
67
+
68
+ // Convert the base_uri to a UriInterface
69
+ if (isset($config['base_uri'])) {
70
+ $config['base_uri'] = Psr7\uri_for($config['base_uri']);
71
+ }
72
+
73
+ $this->configureDefaults($config);
74
+ }
75
+
76
+ public function __call($method, $args)
77
+ {
78
+ if (count($args) < 1) {
79
+ throw new \InvalidArgumentException('Magic request methods require a URI and optional options array');
80
+ }
81
+
82
+ $uri = $args[0];
83
+ $opts = isset($args[1]) ? $args[1] : [];
84
+
85
+ return substr($method, -5) === 'Async'
86
+ ? $this->requestAsync(substr($method, 0, -5), $uri, $opts)
87
+ : $this->request($method, $uri, $opts);
88
+ }
89
+
90
+ public function sendAsync(RequestInterface $request, array $options = [])
91
+ {
92
+ // Merge the base URI into the request URI if needed.
93
+ $options = $this->prepareDefaults($options);
94
+
95
+ return $this->transfer(
96
+ $request->withUri($this->buildUri($request->getUri(), $options)),
97
+ $options
98
+ );
99
+ }
100
+
101
+ public function send(RequestInterface $request, array $options = [])
102
+ {
103
+ $options[RequestOptions::SYNCHRONOUS] = true;
104
+ return $this->sendAsync($request, $options)->wait();
105
+ }
106
+
107
+ public function requestAsync($method, $uri = null, array $options = [])
108
+ {
109
+ $options = $this->prepareDefaults($options);
110
+ // Remove request modifying parameter because it can be done up-front.
111
+ $headers = isset($options['headers']) ? $options['headers'] : [];
112
+ $body = isset($options['body']) ? $options['body'] : null;
113
+ $version = isset($options['version']) ? $options['version'] : '1.1';
114
+ // Merge the URI into the base URI.
115
+ $uri = $this->buildUri($uri, $options);
116
+ if (is_array($body)) {
117
+ $this->invalidBody();
118
+ }
119
+ $request = new Psr7\Request($method, $uri, $headers, $body, $version);
120
+ // Remove the option so that they are not doubly-applied.
121
+ unset($options['headers'], $options['body'], $options['version']);
122
+
123
+ return $this->transfer($request, $options);
124
+ }
125
+
126
+ public function request($method, $uri = null, array $options = [])
127
+ {
128
+ $options[RequestOptions::SYNCHRONOUS] = true;
129
+ return $this->requestAsync($method, $uri, $options)->wait();
130
+ }
131
+
132
+ public function getConfig($option = null)
133
+ {
134
+ return $option === null
135
+ ? $this->config
136
+ : (isset($this->config[$option]) ? $this->config[$option] : null);
137
+ }
138
+
139
+ private function buildUri($uri, array $config)
140
+ {
141
+ if (!isset($config['base_uri'])) {
142
+ return $uri instanceof UriInterface ? $uri : new Psr7\Uri($uri);
143
+ }
144
+
145
+ return Psr7\Uri::resolve(Psr7\uri_for($config['base_uri']), $uri);
146
+ }
147
+
148
+ /**
149
+ * Configures the default options for a client.
150
+ *
151
+ * @param array $config
152
+ */
153
+ private function configureDefaults(array $config)
154
+ {
155
+ $defaults = [
156
+ 'allow_redirects' => RedirectMiddleware::$defaultSettings,
157
+ 'http_errors' => true,
158
+ 'decode_content' => true,
159
+ 'verify' => true,
160
+ 'cookies' => false
161
+ ];
162
+
163
+ // Use the standard Linux HTTP_PROXY and HTTPS_PROXY if set
164
+ if ($proxy = getenv('HTTP_PROXY')) {
165
+ $defaults['proxy']['http'] = $proxy;
166
+ }
167
+
168
+ if ($proxy = getenv('HTTPS_PROXY')) {
169
+ $defaults['proxy']['https'] = $proxy;
170
+ }
171
+
172
+ if ($noProxy = getenv('NO_PROXY')) {
173
+ $cleanedNoProxy = str_replace(' ', '', $noProxy);
174
+ $defaults['proxy']['no'] = explode(',', $cleanedNoProxy);
175
+ }
176
+
177
+ $this->config = $config + $defaults;
178
+
179
+ if (!empty($config['cookies']) && $config['cookies'] === true) {
180
+ $this->config['cookies'] = new CookieJar();
181
+ }
182
+
183
+ // Add the default user-agent header.
184
+ if (!isset($this->config['headers'])) {
185
+ $this->config['headers'] = ['User-Agent' => default_user_agent()];
186
+ } else {
187
+ // Add the User-Agent header if one was not already set.
188
+ foreach (array_keys($this->config['headers']) as $name) {
189
+ if (strtolower($name) === 'user-agent') {
190
+ return;
191
+ }
192
+ }
193
+ $this->config['headers']['User-Agent'] = default_user_agent();
194
+ }
195
+ }
196
+
197
+ /**
198
+ * Merges default options into the array.
199
+ *
200
+ * @param array $options Options to modify by reference
201
+ *
202
+ * @return array
203
+ */
204
+ private function prepareDefaults($options)
205
+ {
206
+ $defaults = $this->config;
207
+
208
+ if (!empty($defaults['headers'])) {
209
+ // Default headers are only added if they are not present.
210
+ $defaults['_conditional'] = $defaults['headers'];
211
+ unset($defaults['headers']);
212
+ }
213
+
214
+ // Special handling for headers is required as they are added as
215
+ // conditional headers and as headers passed to a request ctor.
216
+ if (array_key_exists('headers', $options)) {
217
+ // Allows default headers to be unset.
218
+ if ($options['headers'] === null) {
219
+ $defaults['_conditional'] = null;
220
+ unset($options['headers']);
221
+ } elseif (!is_array($options['headers'])) {
222
+ throw new \InvalidArgumentException('headers must be an array');
223
+ }
224
+ }
225
+
226
+ // Shallow merge defaults underneath options.
227
+ $result = $options + $defaults;
228
+
229
+ // Remove null values.
230
+ foreach ($result as $k => $v) {
231
+ if ($v === null) {
232
+ unset($result[$k]);
233
+ }
234
+ }
235
+
236
+ return $result;
237
+ }
238
+
239
+ /**
240
+ * Transfers the given request and applies request options.
241
+ *
242
+ * The URI of the request is not modified and the request options are used
243
+ * as-is without merging in default options.
244
+ *
245
+ * @param RequestInterface $request
246
+ * @param array $options
247
+ *
248
+ * @return Promise\PromiseInterface
249
+ */
250
+ private function transfer(RequestInterface $request, array $options)
251
+ {
252
+ // save_to -> sink
253
+ if (isset($options['save_to'])) {
254
+ $options['sink'] = $options['save_to'];
255
+ unset($options['save_to']);
256
+ }
257
+
258
+ // exceptions -> http_error
259
+ if (isset($options['exceptions'])) {
260
+ $options['http_errors'] = $options['exceptions'];
261
+ unset($options['exceptions']);
262
+ }
263
+
264
+ $request = $this->applyOptions($request, $options);
265
+ $handler = $options['handler'];
266
+
267
+ try {
268
+ return Promise\promise_for($handler($request, $options));
269
+ } catch (\Exception $e) {
270
+ return Promise\rejection_for($e);
271
+ }
272
+ }
273
+
274
+ /**
275
+ * Applies the array of request options to a request.
276
+ *
277
+ * @param RequestInterface $request
278
+ * @param array $options
279
+ *
280
+ * @return RequestInterface
281
+ */
282
+ private function applyOptions(RequestInterface $request, array &$options)
283
+ {
284
+ $modify = [];
285
+
286
+ if (isset($options['form_params'])) {
287
+ if (isset($options['multipart'])) {
288
+ throw new \InvalidArgumentException('You cannot use '
289
+ . 'form_params and multipart at the same time. Use the '
290
+ . 'form_params option if you want to send application/'
291
+ . 'x-www-form-urlencoded requests, and the multipart '
292
+ . 'option to send multipart/form-data requests.');
293
+ }
294
+ $options['body'] = http_build_query($options['form_params'], null, '&');
295
+ unset($options['form_params']);
296
+ $options['_conditional']['Content-Type'] = 'application/x-www-form-urlencoded';
297
+ }
298
+
299
+ if (isset($options['multipart'])) {
300
+ $elements = $options['multipart'];
301
+ unset($options['multipart']);
302
+ $options['body'] = new Psr7\MultipartStream($elements);
303
+ }
304
+
305
+ if (!empty($options['decode_content'])
306
+ && $options['decode_content'] !== true
307
+ ) {
308
+ $modify['set_headers']['Accept-Encoding'] = $options['decode_content'];
309
+ }
310
+
311
+ if (isset($options['headers'])) {
312
+ if (isset($modify['set_headers'])) {
313
+ $modify['set_headers'] = $options['headers'] + $modify['set_headers'];
314
+ } else {
315
+ $modify['set_headers'] = $options['headers'];
316
+ }
317
+ unset($options['headers']);
318
+ }
319
+
320
+ if (isset($options['body'])) {
321
+ if (is_array($options['body'])) {
322
+ $this->invalidBody();
323
+ }
324
+ $modify['body'] = Psr7\stream_for($options['body']);
325
+ unset($options['body']);
326
+ }
327
+
328
+ if (!empty($options['auth'])) {
329
+ $value = $options['auth'];
330
+ $type = is_array($value)
331
+ ? (isset($value[2]) ? strtolower($value[2]) : 'basic')
332
+ : $value;
333
+ $config['auth'] = $value;
334
+ switch (strtolower($type)) {
335
+ case 'basic':
336
+ $modify['set_headers']['Authorization'] = 'Basic '
337
+ . base64_encode("$value[0]:$value[1]");
338
+ break;
339
+ case 'digest':
340
+ // @todo: Do not rely on curl
341
+ $options['curl'][CURLOPT_HTTPAUTH] = CURLAUTH_DIGEST;
342
+ $options['curl'][CURLOPT_USERPWD] = "$value[0]:$value[1]";
343
+ break;
344
+ }
345
+ }
346
+
347
+ if (isset($options['query'])) {
348
+ $value = $options['query'];
349
+ if (is_array($value)) {
350
+ $value = http_build_query($value, null, '&', PHP_QUERY_RFC3986);
351
+ }
352
+ if (!is_string($value)) {
353
+ throw new \InvalidArgumentException('query must be a string or array');
354
+ }
355
+ $modify['query'] = $value;
356
+ unset($options['query']);
357
+ }
358
+
359
+ if (isset($options['json'])) {
360
+ $modify['body'] = Psr7\stream_for(json_encode($options['json']));
361
+ $options['_conditional']['Content-Type'] = 'application/json';
362
+ unset($options['json']);
363
+ }
364
+
365
+ $request = Psr7\modify_request($request, $modify);
366
+ if ($request->getBody() instanceof Psr7\MultipartStream) {
367
+ // Use a multipart/form-data POST if a Content-Type is not set.
368
+ $options['_conditional']['Content-Type'] = 'multipart/form-data; boundary='
369
+ . $request->getBody()->getBoundary();
370
+ }
371
+
372
+ // Merge in conditional headers if they are not present.
373
+ if (isset($options['_conditional'])) {
374
+ // Build up the changes so it's in a single clone of the message.
375
+ $modify = [];
376
+ foreach ($options['_conditional'] as $k => $v) {
377
+ if (!$request->hasHeader($k)) {
378
+ $modify['set_headers'][$k] = $v;
379
+ }
380
+ }
381
+ $request = Psr7\modify_request($request, $modify);
382
+ // Don't pass this internal value along to middleware/handlers.
383
+ unset($options['_conditional']);
384
+ }
385
+
386
+ return $request;
387
+ }
388
+
389
+ private function invalidBody()
390
+ {
391
+ throw new \InvalidArgumentException('Passing in the "body" request '
392
+ . 'option as an array to send a POST request has been deprecated. '
393
+ . 'Please use the "form_params" request option to send a '
394
+ . 'application/x-www-form-urlencoded request, or a the "multipart" '
395
+ . 'request option to send a multipart/form-data request.');
396
+ }
397
+ }
app/api/Ctct/vendor/guzzlehttp/guzzle/src/ClientInterface.php ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp;
3
+
4
+ use GuzzleHttp\Promise\PromiseInterface;
5
+ use GuzzleHttp\Exception\GuzzleException;
6
+ use Psr\Http\Message\RequestInterface;
7
+ use Psr\Http\Message\ResponseInterface;
8
+ use Psr\Http\Message\UriInterface;
9
+
10
+ /**
11
+ * Client interface for sending HTTP requests.
12
+ */
13
+ interface ClientInterface
14
+ {
15
+ const VERSION = '6.1.1';
16
+
17
+ /**
18
+ * Send an HTTP request.
19
+ *
20
+ * @param RequestInterface $request Request to send
21
+ * @param array $options Request options to apply to the given
22
+ * request and to the transfer.
23
+ *
24
+ * @return ResponseInterface
25
+ * @throws GuzzleException
26
+ */
27
+ public function send(RequestInterface $request, array $options = []);
28
+
29
+ /**
30
+ * Asynchronously send an HTTP request.
31
+ *
32
+ * @param RequestInterface $request Request to send
33
+ * @param array $options Request options to apply to the given
34
+ * request and to the transfer.
35
+ *
36
+ * @return PromiseInterface
37
+ */
38
+ public function sendAsync(RequestInterface $request, array $options = []);
39
+
40
+ /**
41
+ * Create and send an HTTP request.
42
+ *
43
+ * Use an absolute path to override the base path of the client, or a
44
+ * relative path to append to the base path of the client. The URL can
45
+ * contain the query string as well.
46
+ *
47
+ * @param string $method HTTP method
48
+ * @param string|UriInterface $uri URI object or string.
49
+ * @param array $options Request options to apply.
50
+ *
51
+ * @return ResponseInterface
52
+ * @throws GuzzleException
53
+ */
54
+ public function request($method, $uri, array $options = []);
55
+
56
+ /**
57
+ * Create and send an asynchronous HTTP request.
58
+ *
59
+ * Use an absolute path to override the base path of the client, or a
60
+ * relative path to append to the base path of the client. The URL can
61
+ * contain the query string as well. Use an array to provide a URL
62
+ * template and additional variables to use in the URL template expansion.
63
+ *
64
+ * @param string $method HTTP method
65
+ * @param string|UriInterface $uri URI object or string.
66
+ * @param array $options Request options to apply.
67
+ *
68
+ * @return PromiseInterface
69
+ */
70
+ public function requestAsync($method, $uri, array $options = []);
71
+
72
+ /**
73
+ * Get a client configuration option.
74
+ *
75
+ * These options include default request options of the client, a "handler"
76
+ * (if utilized by the concrete client), and a "base_uri" if utilized by
77
+ * the concrete client.
78
+ *
79
+ * @param string|null $option The config option to retrieve.
80
+ *
81
+ * @return mixed
82
+ */
83
+ public function getConfig($option = null);
84
+ }
app/api/Ctct/vendor/guzzlehttp/guzzle/src/Cookie/CookieJar.php ADDED
@@ -0,0 +1,277 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Cookie;
3
+
4
+ use Psr\Http\Message\RequestInterface;
5
+ use Psr\Http\Message\ResponseInterface;
6
+
7
+ /**
8
+ * Cookie jar that stores cookies an an array
9
+ */
10
+ class CookieJar implements CookieJarInterface
11
+ {
12
+ /** @var SetCookie[] Loaded cookie data */
13
+ private $cookies = [];
14
+
15
+ /** @var bool */
16
+ private $strictMode;
17
+
18
+ /**
19
+ * @param bool $strictMode Set to true to throw exceptions when invalid
20
+ * cookies are added to the cookie jar.
21
+ * @param array $cookieArray Array of SetCookie objects or a hash of
22
+ * arrays that can be used with the SetCookie
23
+ * constructor
24
+ */
25
+ public function __construct($strictMode = false, $cookieArray = [])
26
+ {
27
+ $this->strictMode = $strictMode;
28
+
29
+ foreach ($cookieArray as $cookie) {
30
+ if (!($cookie instanceof SetCookie)) {
31
+ $cookie = new SetCookie($cookie);
32
+ }
33
+ $this->setCookie($cookie);
34
+ }
35
+ }
36
+
37
+ /**
38
+ * Create a new Cookie jar from an associative array and domain.
39
+ *
40
+ * @param array $cookies Cookies to create the jar from
41
+ * @param string $domain Domain to set the cookies to
42
+ *
43
+ * @return self
44
+ */
45
+ public static function fromArray(array $cookies, $domain)
46
+ {
47
+ $cookieJar = new self();
48
+ foreach ($cookies as $name => $value) {
49
+ $cookieJar->setCookie(new SetCookie([
50
+ 'Domain' => $domain,
51
+ 'Name' => $name,
52
+ 'Value' => $value,
53
+ 'Discard' => true
54
+ ]));
55
+ }
56
+
57
+ return $cookieJar;
58
+ }
59
+
60
+ /**
61
+ * Quote the cookie value if it is not already quoted and it contains
62
+ * problematic characters.
63
+ *
64
+ * @param string $value Value that may or may not need to be quoted
65
+ *
66
+ * @return string
67
+ */
68
+ public static function getCookieValue($value)
69
+ {
70
+ if (substr($value, 0, 1) !== '"' &&
71
+ substr($value, -1, 1) !== '"' &&
72
+ strpbrk($value, ';,=')
73
+ ) {
74
+ $value = '"' . $value . '"';
75
+ }
76
+
77
+ return $value;
78
+ }
79
+
80
+ /**
81
+ * Evaluate if this cookie should be persisted to storage
82
+ * that survives between requests.
83
+ *
84
+ * @param SetCookie $cookie Being evaluated.
85
+ * @param bool $allowSessionCookies If we should persist session cookies
86
+ * @return bool
87
+ */
88
+ public static function shouldPersist(
89
+ SetCookie $cookie,
90
+ $allowSessionCookies = false
91
+ ) {
92
+ if ($cookie->getExpires() || $allowSessionCookies) {
93
+ if (!$cookie->getDiscard()) {
94
+ return true;
95
+ }
96
+ }
97
+
98
+ return false;
99
+ }
100
+
101
+ public function toArray()
102
+ {
103
+ return array_map(function (SetCookie $cookie) {
104
+ return $cookie->toArray();
105
+ }, $this->getIterator()->getArrayCopy());
106
+ }
107
+
108
+ public function clear($domain = null, $path = null, $name = null)
109
+ {
110
+ if (!$domain) {
111
+ $this->cookies = [];
112
+ return;
113
+ } elseif (!$path) {
114
+ $this->cookies = array_filter(
115
+ $this->cookies,
116
+ function (SetCookie $cookie) use ($path, $domain) {
117
+ return !$cookie->matchesDomain($domain);
118
+ }
119
+ );
120
+ } elseif (!$name) {
121
+ $this->cookies = array_filter(
122
+ $this->cookies,
123
+ function (SetCookie $cookie) use ($path, $domain) {
124
+ return !($cookie->matchesPath($path) &&
125
+ $cookie->matchesDomain($domain));
126
+ }
127
+ );
128
+ } else {
129
+ $this->cookies = array_filter(
130
+ $this->cookies,
131
+ function (SetCookie $cookie) use ($path, $domain, $name) {
132
+ return !($cookie->getName() == $name &&
133
+ $cookie->matchesPath($path) &&
134
+ $cookie->matchesDomain($domain));
135
+ }
136
+ );
137
+ }
138
+ }
139
+
140
+ public function clearSessionCookies()
141
+ {
142
+ $this->cookies = array_filter(
143
+ $this->cookies,
144
+ function (SetCookie $cookie) {
145
+ return !$cookie->getDiscard() && $cookie->getExpires();
146
+ }
147
+ );
148
+ }
149
+
150
+ public function setCookie(SetCookie $cookie)
151
+ {
152
+ // If the name string is empty (but not 0), ignore the set-cookie
153
+ // string entirely.
154
+ $name = $cookie->getName();
155
+ if (!$name && $name !== '0') {
156
+ return false;
157
+ }
158
+
159
+ // Only allow cookies with set and valid domain, name, value
160
+ $result = $cookie->validate();
161
+ if ($result !== true) {
162
+ if ($this->strictMode) {
163
+ throw new \RuntimeException('Invalid cookie: ' . $result);
164
+ } else {
165
+ $this->removeCookieIfEmpty($cookie);
166
+ return false;
167
+ }
168
+ }
169
+
170
+ // Resolve conflicts with previously set cookies
171
+ foreach ($this->cookies as $i => $c) {
172
+
173
+ // Two cookies are identical, when their path, and domain are
174
+ // identical.
175
+ if ($c->getPath() != $cookie->getPath() ||
176
+ $c->getDomain() != $cookie->getDomain() ||
177
+ $c->getName() != $cookie->getName()
178
+ ) {
179
+ continue;
180
+ }
181
+
182
+ // The previously set cookie is a discard cookie and this one is
183
+ // not so allow the new cookie to be set
184
+ if (!$cookie->getDiscard() && $c->getDiscard()) {
185
+ unset($this->cookies[$i]);
186
+ continue;
187
+ }
188
+
189
+ // If the new cookie's expiration is further into the future, then
190
+ // replace the old cookie
191
+ if ($cookie->getExpires() > $c->getExpires()) {
192
+ unset($this->cookies[$i]);
193
+ continue;
194
+ }
195
+
196
+ // If the value has changed, we better change it
197
+ if ($cookie->getValue() !== $c->getValue()) {
198
+ unset($this->cookies[$i]);
199
+ continue;
200
+ }
201
+
202
+ // The cookie exists, so no need to continue
203
+ return false;
204
+ }
205
+
206
+ $this->cookies[] = $cookie;
207
+
208
+ return true;
209
+ }
210
+
211
+ public function count()
212
+ {
213
+ return count($this->cookies);
214
+ }
215
+
216
+ public function getIterator()
217
+ {
218
+ return new \ArrayIterator(array_values($this->cookies));
219
+ }
220
+
221
+ public function extractCookies(
222
+ RequestInterface $request,
223
+ ResponseInterface $response
224
+ ) {
225
+ if ($cookieHeader = $response->getHeader('Set-Cookie')) {
226
+ foreach ($cookieHeader as $cookie) {
227
+ $sc = SetCookie::fromString($cookie);
228
+ if (!$sc->getDomain()) {
229
+ $sc->setDomain($request->getUri()->getHost());
230
+ }
231
+ $this->setCookie($sc);
232
+ }
233
+ }
234
+ }
235
+
236
+ public function withCookieHeader(RequestInterface $request)
237
+ {
238
+ $values = [];
239
+ $uri = $request->getUri();
240
+ $scheme = $uri->getScheme();
241
+ $host = $uri->getHost();
242
+ $path = $uri->getPath() ?: '/';
243
+
244
+ foreach ($this->cookies as $cookie) {
245
+ if ($cookie->matchesPath($path) &&
246
+ $cookie->matchesDomain($host) &&
247
+ !$cookie->isExpired() &&
248
+ (!$cookie->getSecure() || $scheme == 'https')
249
+ ) {
250
+ $values[] = $cookie->getName() . '='
251
+ . self::getCookieValue($cookie->getValue());
252
+ }
253
+ }
254
+
255
+ return $values
256
+ ? $request->withHeader('Cookie', implode('; ', $values))
257
+ : $request;
258
+ }
259
+
260
+ /**
261
+ * If a cookie already exists and the server asks to set it again with a
262
+ * null value, the cookie must be deleted.
263
+ *
264
+ * @param SetCookie $cookie
265
+ */
266
+ private function removeCookieIfEmpty(SetCookie $cookie)
267
+ {
268
+ $cookieValue = $cookie->getValue();
269
+ if ($cookieValue === null || $cookieValue === '') {
270
+ $this->clear(
271
+ $cookie->getDomain(),
272
+ $cookie->getPath(),
273
+ $cookie->getName()
274
+ );
275
+ }
276
+ }
277
+ }
app/api/Ctct/vendor/guzzlehttp/guzzle/src/Cookie/CookieJarInterface.php ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Cookie;
3
+
4
+ use Psr\Http\Message\RequestInterface;
5
+ use Psr\Http\Message\ResponseInterface;
6
+
7
+ /**
8
+ * Stores HTTP cookies.
9
+ *
10
+ * It extracts cookies from HTTP requests, and returns them in HTTP responses.
11
+ * CookieJarInterface instances automatically expire contained cookies when
12
+ * necessary. Subclasses are also responsible for storing and retrieving
13
+ * cookies from a file, database, etc.
14
+ *
15
+ * @link http://docs.python.org/2/library/cookielib.html Inspiration
16
+ */
17
+ interface CookieJarInterface extends \Countable, \IteratorAggregate
18
+ {
19
+ /**
20
+ * Create a request with added cookie headers.
21
+ *
22
+ * If no matching cookies are found in the cookie jar, then no Cookie
23
+ * header is added to the request and the same request is returned.
24
+ *
25
+ * @param RequestInterface $request Request object to modify.
26
+ *
27
+ * @return RequestInterface returns the modified request.
28
+ */
29
+ public function withCookieHeader(RequestInterface $request);
30
+
31
+ /**
32
+ * Extract cookies from an HTTP response and store them in the CookieJar.
33
+ *
34
+ * @param RequestInterface $request Request that was sent
35
+ * @param ResponseInterface $response Response that was received
36
+ */
37
+ public function extractCookies(
38
+ RequestInterface $request,
39
+ ResponseInterface $response
40
+ );
41
+
42
+ /**
43
+ * Sets a cookie in the cookie jar.
44
+ *
45
+ * @param SetCookie $cookie Cookie to set.
46
+ *
47
+ * @return bool Returns true on success or false on failure
48
+ */
49
+ public function setCookie(SetCookie $cookie);
50
+
51
+ /**
52
+ * Remove cookies currently held in the cookie jar.
53
+ *
54
+ * Invoking this method without arguments will empty the whole cookie jar.
55
+ * If given a $domain argument only cookies belonging to that domain will
56
+ * be removed. If given a $domain and $path argument, cookies belonging to
57
+ * the specified path within that domain are removed. If given all three
58
+ * arguments, then the cookie with the specified name, path and domain is
59
+ * removed.
60
+ *
61
+ * @param string $domain Clears cookies matching a domain
62
+ * @param string $path Clears cookies matching a domain and path
63
+ * @param string $name Clears cookies matching a domain, path, and name
64
+ *
65
+ * @return CookieJarInterface
66
+ */
67
+ public function clear($domain = null, $path = null, $name = null);
68
+
69
+ /**
70
+ * Discard all sessions cookies.
71
+ *
72
+ * Removes cookies that don't have an expire field or a have a discard
73
+ * field set to true. To be called when the user agent shuts down according
74
+ * to RFC 2965.
75
+ */
76
+ public function clearSessionCookies();
77
+
78
+ /**
79
+ * Converts the cookie jar to an array.
80
+ *
81
+ * @return array
82
+ */
83
+ public function toArray();
84
+ }
app/api/Ctct/vendor/guzzlehttp/guzzle/src/Cookie/FileCookieJar.php ADDED
@@ -0,0 +1,87 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Cookie;
3
+
4
+ /**
5
+ * Persists non-session cookies using a JSON formatted file
6
+ */
7
+ class FileCookieJar extends CookieJar
8
+ {
9
+ /** @var string filename */
10
+ private $filename;
11
+
12
+ /** @var bool Control whether to persist session cookies or not. */
13
+ private $storeSessionCookies;
14
+
15
+ /**
16
+ * Create a new FileCookieJar object
17
+ *
18
+ * @param string $cookieFile File to store the cookie data
19
+ * @param bool $storeSessionCookies Set to true to store session cookies
20
+ * in the cookie jar.
21
+ *
22
+ * @throws \RuntimeException if the file cannot be found or created
23
+ */
24
+ public function __construct($cookieFile, $storeSessionCookies = false)
25
+ {
26
+ $this->filename = $cookieFile;
27
+ $this->storeSessionCookies = $storeSessionCookies;
28
+
29
+ if (file_exists($cookieFile)) {
30
+ $this->load($cookieFile);
31
+ }
32
+ }
33
+
34
+ /**
35
+ * Saves the file when shutting down
36
+ */
37
+ public function __destruct()
38
+ {
39
+ $this->save($this->filename);
40
+ }
41
+
42
+ /**
43
+ * Saves the cookies to a file.
44
+ *
45
+ * @param string $filename File to save
46
+ * @throws \RuntimeException if the file cannot be found or created
47
+ */
48
+ public function save($filename)
49
+ {
50
+ $json = [];
51
+ foreach ($this as $cookie) {
52
+ /** @var SetCookie $cookie */
53
+ if (CookieJar::shouldPersist($cookie, $this->storeSessionCookies)) {
54
+ $json[] = $cookie->toArray();
55
+ }
56
+ }
57
+
58
+ if (false === file_put_contents($filename, json_encode($json))) {
59
+ throw new \RuntimeException("Unable to save file {$filename}");
60
+ }
61
+ }
62
+
63
+ /**
64
+ * Load cookies from a JSON formatted file.
65
+ *
66
+ * Old cookies are kept unless overwritten by newly loaded ones.
67
+ *
68
+ * @param string $filename Cookie file to load.
69
+ * @throws \RuntimeException if the file cannot be loaded.
70
+ */
71
+ public function load($filename)
72
+ {
73
+ $json = file_get_contents($filename);
74
+ if (false === $json) {
75
+ throw new \RuntimeException("Unable to load file {$filename}");
76
+ }
77
+
78
+ $data = json_decode($json, true);
79
+ if (is_array($data)) {
80
+ foreach (json_decode($json, true) as $cookie) {
81
+ $this->setCookie(new SetCookie($cookie));
82
+ }
83
+ } elseif (strlen($data)) {
84
+ throw new \RuntimeException("Invalid cookie file: {$filename}");
85
+ }
86
+ }
87
+ }
app/api/Ctct/vendor/guzzlehttp/guzzle/src/Cookie/SessionCookieJar.php ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Cookie;
3
+
4
+ /**
5
+ * Persists cookies in the client session
6
+ */
7
+ class SessionCookieJar extends CookieJar
8
+ {
9
+ /** @var string session key */
10
+ private $sessionKey;
11
+
12
+ /** @var bool Control whether to persist session cookies or not. */
13
+ private $storeSessionCookies;
14
+
15
+ /**
16
+ * Create a new SessionCookieJar object
17
+ *
18
+ * @param string $sessionKey Session key name to store the cookie
19
+ * data in session
20
+ * @param bool $storeSessionCookies Set to true to store session cookies
21
+ * in the cookie jar.
22
+ */
23
+ public function __construct($sessionKey, $storeSessionCookies = false)
24
+ {
25
+ $this->sessionKey = $sessionKey;
26
+ $this->storeSessionCookies = $storeSessionCookies;
27
+ $this->load();
28
+ }
29
+
30
+ /**
31
+ * Saves cookies to session when shutting down
32
+ */
33
+ public function __destruct()
34
+ {
35
+ $this->save();
36
+ }
37
+
38
+ /**
39
+ * Save cookies to the client session
40
+ */
41
+ public function save()
42
+ {
43
+ $json = [];
44
+ foreach ($this as $cookie) {
45
+ /** @var SetCookie $cookie */
46
+ if (CookieJar::shouldPersist($cookie, $this->storeSessionCookies)) {
47
+ $json[] = $cookie->toArray();
48
+ }
49
+ }
50
+
51
+ $_SESSION[$this->sessionKey] = json_encode($json);
52
+ }
53
+
54
+ /**
55
+ * Load the contents of the client session into the data array
56
+ */
57
+ protected function load()
58
+ {
59
+ $cookieJar = isset($_SESSION[$this->sessionKey])
60
+ ? $_SESSION[$this->sessionKey]
61
+ : null;
62
+
63
+ $data = json_decode($cookieJar, true);
64
+ if (is_array($data)) {
65
+ foreach ($data as $cookie) {
66
+ $this->setCookie(new SetCookie($cookie));
67
+ }
68
+ } elseif (strlen($data)) {
69
+ throw new \RuntimeException("Invalid cookie data");
70
+ }
71
+ }
72
+ }
app/api/Ctct/vendor/guzzlehttp/guzzle/src/Cookie/SetCookie.php ADDED
@@ -0,0 +1,404 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Cookie;
3
+
4
+ /**
5
+ * Set-Cookie object
6
+ */
7
+ class SetCookie
8
+ {
9
+ /** @var array */
10
+ private static $defaults = [
11
+ 'Name' => null,
12
+ 'Value' => null,
13
+ 'Domain' => null,
14
+ 'Path' => '/',
15
+ 'Max-Age' => null,
16
+ 'Expires' => null,
17
+ 'Secure' => false,
18
+ 'Discard' => false,
19
+ 'HttpOnly' => false
20
+ ];
21
+
22
+ /** @var array Cookie data */
23
+ private $data;
24
+
25
+ /**
26
+ * Create a new SetCookie object from a string
27
+ *
28
+ * @param string $cookie Set-Cookie header string
29
+ *
30
+ * @return self
31
+ */
32
+ public static function fromString($cookie)
33
+ {
34
+ // Create the default return array
35
+ $data = self::$defaults;
36
+ // Explode the cookie string using a series of semicolons
37
+ $pieces = array_filter(array_map('trim', explode(';', $cookie)));
38
+ // The name of the cookie (first kvp) must include an equal sign.
39
+ if (empty($pieces) || !strpos($pieces[0], '=')) {
40
+ return new self($data);
41
+ }
42
+
43
+ // Add the cookie pieces into the parsed data array
44
+ foreach ($pieces as $part) {
45
+
46
+ $cookieParts = explode('=', $part, 2);
47
+ $key = trim($cookieParts[0]);
48
+ $value = isset($cookieParts[1])
49
+ ? trim($cookieParts[1], " \n\r\t\0\x0B")
50
+ : true;
51
+
52
+ // Only check for non-cookies when cookies have been found
53
+ if (empty($data['Name'])) {
54
+ $data['Name'] = $key;
55
+ $data['Value'] = $value;
56
+ } else {
57
+ foreach (array_keys(self::$defaults) as $search) {
58
+ if (!strcasecmp($search, $key)) {
59
+ $data[$search] = $value;
60
+ continue 2;
61
+ }
62
+ }
63
+ $data[$key] = $value;
64
+ }
65
+ }
66
+
67
+ return new self($data);
68
+ }
69
+
70
+ /**
71
+ * @param array $data Array of cookie data provided by a Cookie parser
72
+ */
73
+ public function __construct(array $data = [])
74
+ {
75
+ $this->data = array_replace(self::$defaults, $data);
76
+ // Extract the Expires value and turn it into a UNIX timestamp if needed
77
+ if (!$this->getExpires() && $this->getMaxAge()) {
78
+ // Calculate the Expires date
79
+ $this->setExpires(time() + $this->getMaxAge());
80
+ } elseif ($this->getExpires() && !is_numeric($this->getExpires())) {
81
+ $this->setExpires($this->getExpires());
82
+ }
83
+ }
84
+
85
+ public function __toString()
86
+ {
87
+ $str = $this->data['Name'] . '=' . $this->data['Value'] . '; ';
88
+ foreach ($this->data as $k => $v) {
89
+ if ($k != 'Name' && $k != 'Value' && $v !== null && $v !== false) {
90
+ if ($k == 'Expires') {
91
+ $str .= 'Expires=' . gmdate('D, d M Y H:i:s \G\M\T', $v) . '; ';
92
+ } else {
93
+ $str .= ($v === true ? $k : "{$k}={$v}") . '; ';
94
+ }
95
+ }
96
+ }
97
+
98
+ return rtrim($str, '; ');
99
+ }
100
+
101
+ public function toArray()
102
+ {
103
+ return $this->data;
104
+ }
105
+
106
+ /**
107
+ * Get the cookie name
108
+ *
109
+ * @return string
110
+ */
111
+ public function getName()
112
+ {
113
+ return $this->data['Name'];
114
+ }
115
+
116
+ /**
117
+ * Set the cookie name
118
+ *
119
+ * @param string $name Cookie name
120
+ */
121
+ public function setName($name)
122
+ {
123
+ $this->data['Name'] = $name;
124
+ }
125
+
126
+ /**
127
+ * Get the cookie value
128
+ *
129
+ * @return string
130
+ */
131
+ public function getValue()
132
+ {
133
+ return $this->data['Value'];
134
+ }
135
+
136
+ /**
137
+ * Set the cookie value
138
+ *
139
+ * @param string $value Cookie value
140
+ */
141
+ public function setValue($value)
142
+ {
143
+ $this->data['Value'] = $value;
144
+ }
145
+
146
+ /**
147
+ * Get the domain
148
+ *
149
+ * @return string|null
150
+ */
151
+ public function getDomain()
152
+ {
153
+ return $this->data['Domain'];
154
+ }
155
+
156
+ /**
157
+ * Set the domain of the cookie
158
+ *
159
+ * @param string $domain
160
+ */
161
+ public function setDomain($domain)
162
+ {
163
+ $this->data['Domain'] = $domain;
164
+ }
165
+
166
+ /**
167
+ * Get the path
168
+ *
169
+ * @return string
170
+ */
171
+ public function getPath()
172
+ {
173
+ return $this->data['Path'];
174
+ }
175
+
176
+ /**
177
+ * Set the path of the cookie
178
+ *
179
+ * @param string $path Path of the cookie
180
+ */
181
+ public function setPath($path)
182
+ {
183
+ $this->data['Path'] = $path;
184
+ }
185
+
186
+ /**
187
+ * Maximum lifetime of the cookie in seconds
188
+ *
189
+ * @return int|null
190
+ */
191
+ public function getMaxAge()
192
+ {
193
+ return $this->data['Max-Age'];
194
+ }
195
+
196
+ /**
197
+ * Set the max-age of the cookie
198
+ *
199
+ * @param int $maxAge Max age of the cookie in seconds
200
+ */
201
+ public function setMaxAge($maxAge)
202
+ {
203
+ $this->data['Max-Age'] = $maxAge;
204
+ }
205
+
206
+ /**
207
+ * The UNIX timestamp when the cookie Expires
208
+ *
209
+ * @return mixed
210
+ */
211
+ public function getExpires()
212
+ {
213
+ return $this->data['Expires'];
214
+ }
215
+
216
+ /**
217
+ * Set the unix timestamp for which the cookie will expire
218
+ *
219
+ * @param int $timestamp Unix timestamp
220
+ */
221
+ public function setExpires($timestamp)
222
+ {
223
+ $this->data['Expires'] = is_numeric($timestamp)
224
+ ? (int) $timestamp
225
+ : strtotime($timestamp);
226
+ }
227
+
228
+ /**
229
+ * Get whether or not this is a secure cookie
230
+ *
231
+ * @return null|bool
232
+ */
233
+ public function getSecure()
234
+ {
235
+ return $this->data['Secure'];
236
+ }
237
+
238
+ /**
239
+ * Set whether or not the cookie is secure
240
+ *
241
+ * @param bool $secure Set to true or false if secure
242
+ */
243
+ public function setSecure($secure)
244
+ {
245
+ $this->data['Secure'] = $secure;
246
+ }
247
+
248
+ /**
249
+ * Get whether or not this is a session cookie
250
+ *
251
+ * @return null|bool
252
+ */
253
+ public function getDiscard()
254
+ {
255
+ return $this->data['Discard'];
256
+ }
257
+
258
+ /**
259
+ * Set whether or not this is a session cookie
260
+ *
261
+ * @param bool $discard Set to true or false if this is a session cookie
262
+ */
263
+ public function setDiscard($discard)
264
+ {
265
+ $this->data['Discard'] = $discard;
266
+ }
267
+
268
+ /**
269
+ * Get whether or not this is an HTTP only cookie
270
+ *
271
+ * @return bool
272
+ */
273
+ public function getHttpOnly()
274
+ {
275
+ return $this->data['HttpOnly'];
276
+ }
277
+
278
+ /**
279
+ * Set whether or not this is an HTTP only cookie
280
+ *
281
+ * @param bool $httpOnly Set to true or false if this is HTTP only
282
+ */
283
+ public function setHttpOnly($httpOnly)
284
+ {
285
+ $this->data['HttpOnly'] = $httpOnly;
286
+ }
287
+
288
+ /**
289
+ * Check if the cookie matches a path value.
290
+ *
291
+ * A request-path path-matches a given cookie-path if at least one of
292
+ * the following conditions holds:
293
+ *
294
+ * - The cookie-path and the request-path are identical.
295
+ * - The cookie-path is a prefix of the request-path, and the last
296
+ * character of the cookie-path is %x2F ("/").
297
+ * - The cookie-path is a prefix of the request-path, and the first
298
+ * character of the request-path that is not included in the cookie-
299
+ * path is a %x2F ("/") character.
300
+ *
301
+ * @param string $requestPath Path to check against
302
+ *
303
+ * @return bool
304
+ */
305
+ public function matchesPath($requestPath)
306
+ {
307
+ $cookiePath = $this->getPath();
308
+
309
+ // Match on exact matches or when path is the default empty "/"
310
+ if ($cookiePath == '/' || $cookiePath == $requestPath) {
311
+ return true;
312
+ }
313
+
314
+ // Ensure that the cookie-path is a prefix of the request path.
315
+ if (0 !== strpos($requestPath, $cookiePath)) {
316
+ return false;
317
+ }
318
+
319
+ // Match if the last character of the cookie-path is "/"
320
+ if (substr($cookiePath, -1, 1) == '/') {
321
+ return true;
322
+ }
323
+
324
+ // Match if the first character not included in cookie path is "/"
325
+ return substr($requestPath, strlen($cookiePath), 1) == '/';
326
+ }
327
+
328
+ /**
329
+ * Check if the cookie matches a domain value
330
+ *
331
+ * @param string $domain Domain to check against
332
+ *
333
+ * @return bool
334
+ */
335
+ public function matchesDomain($domain)
336
+ {
337
+ // Remove the leading '.' as per spec in RFC 6265.
338
+ // http://tools.ietf.org/html/rfc6265#section-5.2.3
339
+ $cookieDomain = ltrim($this->getDomain(), '.');
340
+
341
+ // Domain not set or exact match.
342
+ if (!$cookieDomain || !strcasecmp($domain, $cookieDomain)) {
343
+ return true;
344
+ }
345
+
346
+ // Matching the subdomain according to RFC 6265.
347
+ // http://tools.ietf.org/html/rfc6265#section-5.1.3
348
+ if (filter_var($domain, FILTER_VALIDATE_IP)) {
349
+ return false;
350
+ }
351
+
352
+ return (bool) preg_match('/\.' . preg_quote($cookieDomain) . '$/', $domain);
353
+ }
354
+
355
+ /**
356
+ * Check if the cookie is expired
357
+ *
358
+ * @return bool
359
+ */
360
+ public function isExpired()
361
+ {
362
+ return $this->getExpires() && time() > $this->getExpires();
363
+ }
364
+
365
+ /**
366
+ * Check if the cookie is valid according to RFC 6265
367
+ *
368
+ * @return bool|string Returns true if valid or an error message if invalid
369
+ */
370
+ public function validate()
371
+ {
372
+ // Names must not be empty, but can be 0
373
+ $name = $this->getName();
374
+ if (empty($name) && !is_numeric($name)) {
375
+ return 'The cookie name must not be empty';
376
+ }
377
+
378
+ // Check if any of the invalid characters are present in the cookie name
379
+ if (preg_match(
380
+ '/[\x00-\x20\x22\x28-\x29\x2c\x2f\x3a-\x40\x5c\x7b\x7d\x7f]/',
381
+ $name)
382
+ ) {
383
+ return 'Cookie name must not contain invalid characters: ASCII '
384
+ . 'Control characters (0-31;127), space, tab and the '
385
+ . 'following characters: ()<>@,;:\"/?={}';
386
+ }
387
+
388
+ // Value must not be empty, but can be 0
389
+ $value = $this->getValue();
390
+ if (empty($value) && !is_numeric($value)) {
391
+ return 'The cookie value must not be empty';
392
+ }
393
+
394
+ // Domains must not be empty, but can be 0
395
+ // A "0" is not a valid internet domain, but may be used as server name
396
+ // in a private network.
397
+ $domain = $this->getDomain();
398
+ if (empty($domain) && !is_numeric($domain)) {
399
+ return 'The cookie domain must not be empty';
400
+ }
401
+
402
+ return true;
403
+ }
404
+ }
app/api/Ctct/vendor/guzzlehttp/guzzle/src/Exception/BadResponseException.php ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Exception;
3
+
4
+ /**
5
+ * Exception when an HTTP error occurs (4xx or 5xx error)
6
+ */
7
+ class BadResponseException extends RequestException {}
app/api/Ctct/vendor/guzzlehttp/guzzle/src/Exception/ClientException.php ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Exception;
3
+
4
+ /**
5
+ * Exception when a client error is encountered (4xx codes)
6
+ */
7
+ class ClientException extends BadResponseException {}
app/api/Ctct/vendor/guzzlehttp/guzzle/src/Exception/ConnectException.php ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Exception;
3
+
4
+ use Psr\Http\Message\RequestInterface;
5
+
6
+ /**
7
+ * Exception thrown when a connection cannot be established.
8
+ *
9
+ * Note that no response is present for a ConnectException
10
+ */
11
+ class ConnectException extends RequestException
12
+ {
13
+ public function __construct(
14
+ $message,
15
+ RequestInterface $request,
16
+ \Exception $previous = null,
17
+ array $handlerContext = []
18
+ ) {
19
+ parent::__construct($message, $request, null, $previous, $handlerContext);
20
+ }
21
+
22
+ /**
23
+ * @return null
24
+ */
25
+ public function getResponse()
26
+ {
27
+ return null;
28
+ }
29
+
30
+ /**
31
+ * @return bool
32
+ */
33
+ public function hasResponse()
34
+ {
35
+ return false;
36
+ }
37
+ }
app/api/Ctct/vendor/guzzlehttp/guzzle/src/Exception/GuzzleException.php ADDED
@@ -0,0 +1,4 @@
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Exception;
3
+
4
+ interface GuzzleException {}
app/api/Ctct/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php ADDED
@@ -0,0 +1,188 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Exception;
3
+
4
+ use Psr\Http\Message\RequestInterface;
5
+ use Psr\Http\Message\ResponseInterface;
6
+ use GuzzleHttp\Promise\PromiseInterface;
7
+
8
+ /**
9
+ * HTTP Request exception
10
+ */
11
+ class RequestException extends TransferException
12
+ {
13
+ /** @var RequestInterface */
14
+ private $request;
15
+
16
+ /** @var ResponseInterface */
17
+ private $response;
18
+
19
+ /** @var array */
20
+ private $handlerContext;
21
+
22
+ public function __construct(
23
+ $message,
24
+ RequestInterface $request,
25
+ ResponseInterface $response = null,
26
+ \Exception $previous = null,
27
+ array $handlerContext = []
28
+ ) {
29
+ // Set the code of the exception if the response is set and not future.
30
+ $code = $response && !($response instanceof PromiseInterface)
31
+ ? $response->getStatusCode()
32
+ : 0;
33
+ parent::__construct($message, $code, $previous);
34
+ $this->request = $request;
35
+ $this->response = $response;
36
+ $this->handlerContext = $handlerContext;
37
+ }
38
+
39
+ /**
40
+ * Wrap non-RequestExceptions with a RequestException
41
+ *
42
+ * @param RequestInterface $request
43
+ * @param \Exception $e
44
+ *
45
+ * @return RequestException
46
+ */
47
+ public static function wrapException(RequestInterface $request, \Exception $e)
48
+ {
49
+ return $e instanceof RequestException
50
+ ? $e
51
+ : new RequestException($e->getMessage(), $request, null, $e);
52
+ }
53
+
54
+ /**
55
+ * Factory method to create a new exception with a normalized error message
56
+ *
57
+ * @param RequestInterface $request Request
58
+ * @param ResponseInterface $response Response received
59
+ * @param \Exception $previous Previous exception
60
+ * @param array $ctx Optional handler context.
61
+ *
62
+ * @return self
63
+ */
64
+ public static function create(
65
+ RequestInterface $request,
66
+ ResponseInterface $response = null,
67
+ \Exception $previous = null,
68
+ array $ctx = []
69
+ ) {
70
+ if (!$response) {
71
+ return new self(
72
+ 'Error completing request',
73
+ $request,
74
+ null,
75
+ $previous,
76
+ $ctx
77
+ );
78
+ }
79
+
80
+ $level = floor($response->getStatusCode() / 100);
81
+ if ($level == '4') {
82
+ $label = 'Client error';
83
+ $className = __NAMESPACE__ . '\\ClientException';
84
+ } elseif ($level == '5') {
85
+ $label = 'Server error';
86
+ $className = __NAMESPACE__ . '\\ServerException';
87
+ } else {
88
+ $label = 'Unsuccessful request';
89
+ $className = __CLASS__;
90
+ }
91
+
92
+ // Server Error: `GET /` resulted in a `404 Not Found` response:
93
+ // <html> ... (truncated)
94
+ $message = sprintf(
95
+ '%s: `%s` resulted in a `%s` response',
96
+ $label,
97
+ $request->getMethod() . ' ' . $request->getUri(),
98
+ $response->getStatusCode() . ' ' . $response->getReasonPhrase()
99
+ );
100
+
101
+ $summary = static::getResponseBodySummary($response);
102
+
103
+ if ($summary !== null) {
104
+ $message .= ":\n{$summary}\n";
105
+ }
106
+
107
+ return new $className($message, $request, $response, $previous, $ctx);
108
+ }
109
+
110
+ /**
111
+ * Get a short summary of the response
112
+ *
113
+ * Will return `null` if the response is not printable.
114
+ *
115
+ * @param ResponseInterface $response
116
+ *
117
+ * @return string|null
118
+ */
119
+ public static function getResponseBodySummary(ResponseInterface $response)
120
+ {
121
+ $body = $response->getBody();
122
+
123
+ if (!$body->isSeekable()) {
124
+ return null;
125
+ }
126
+
127
+ $size = $body->getSize();
128
+ $summary = $body->read(120);
129
+ $body->rewind();
130
+
131
+ if ($size > 120) {
132
+ $summary .= ' (truncated...)';
133
+ }
134
+
135
+ // Matches any printable character, including unicode characters:
136
+ // letters, marks, numbers, punctuation, spacing, and separators.
137
+ if (preg_match('/[^\pL\pM\pN\pP\pS\pZ\n\r\t]/', $summary)) {
138
+ return null;
139
+ }
140
+
141
+ return $summary;
142
+ }
143
+
144
+ /**
145
+ * Get the request that caused the exception
146
+ *
147
+ * @return RequestInterface
148
+ */
149
+ public function getRequest()
150
+ {
151
+ return $this->request;
152
+ }
153
+
154
+ /**
155
+ * Get the associated response
156
+ *
157
+ * @return ResponseInterface|null
158
+ */
159
+ public function getResponse()
160
+ {
161
+ return $this->response;
162
+ }
163
+
164
+ /**
165
+ * Check if a response was received
166
+ *
167
+ * @return bool
168
+ */
169
+ public function hasResponse()
170
+ {
171
+ return $this->response !== null;
172
+ }
173
+
174
+ /**
175
+ * Get contextual information about the error from the underlying handler.
176
+ *
177
+ * The contents of this array will vary depending on which handler you are
178
+ * using. It may also be just an empty array. Relying on this data will
179
+ * couple you to a specific handler, but can give more debug information
180
+ * when needed.
181
+ *
182
+ * @return array
183
+ */
184
+ public function getHandlerContext()
185
+ {
186
+ return $this->handlerContext;
187
+ }
188
+ }
app/api/Ctct/vendor/guzzlehttp/guzzle/src/Exception/SeekException.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Exception;
3
+
4
+ use Psr\Http\Message\StreamInterface;
5
+
6
+ /**
7
+ * Exception thrown when a seek fails on a stream.
8
+ */
9
+ class SeekException extends \RuntimeException implements GuzzleException
10
+ {
11
+ private $stream;
12
+
13
+ public function __construct(StreamInterface $stream, $pos = 0, $msg = '')
14
+ {
15
+ $this->stream = $stream;
16
+ $msg = $msg ?: 'Could not seek the stream to position ' . $pos;
17
+ parent::__construct($msg);
18
+ }
19
+
20
+ /**
21
+ * @return StreamInterface
22
+ */
23
+ public function getStream()
24
+ {
25
+ return $this->stream;
26
+ }
27
+ }
app/api/Ctct/vendor/guzzlehttp/guzzle/src/Exception/ServerException.php ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Exception;
3
+
4
+ /**
5
+ * Exception when a server error is encountered (5xx codes)
6
+ */
7
+ class ServerException extends BadResponseException {}
app/api/Ctct/vendor/guzzlehttp/guzzle/src/Exception/TooManyRedirectsException.php ADDED
@@ -0,0 +1,4 @@
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Exception;
3
+
4
+ class TooManyRedirectsException extends RequestException {}
app/api/Ctct/vendor/guzzlehttp/guzzle/src/Exception/TransferException.php ADDED
@@ -0,0 +1,4 @@
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Exception;
3
+
4
+ class TransferException extends \RuntimeException implements GuzzleException {}
app/api/Ctct/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php ADDED
@@ -0,0 +1,531 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Handler;
3
+
4
+ use GuzzleHttp\Exception\RequestException;
5
+ use GuzzleHttp\Exception\ConnectException;
6
+ use GuzzleHttp\Promise\FulfilledPromise;
7
+ use GuzzleHttp\Promise\RejectedPromise;
8
+ use GuzzleHttp\Psr7;
9
+ use GuzzleHttp\Psr7\LazyOpenStream;
10
+ use GuzzleHttp\TransferStats;
11
+ use Psr\Http\Message\RequestInterface;
12
+
13
+ /**
14
+ * Creates curl resources from a request
15
+ */
16
+ class CurlFactory implements CurlFactoryInterface
17
+ {
18
+ /** @var array */
19
+ private $handles;
20
+
21
+ /** @var int Total number of idle handles to keep in cache */
22
+ private $maxHandles;
23
+
24
+ /**
25
+ * @param int $maxHandles Maximum number of idle handles.
26
+ */
27
+ public function __construct($maxHandles)
28
+ {
29
+ $this->maxHandles = $maxHandles;
30
+ }
31
+
32
+ public function create(RequestInterface $request, array $options)
33
+ {
34
+ if (isset($options['curl']['body_as_string'])) {
35
+ $options['_body_as_string'] = $options['curl']['body_as_string'];
36
+ unset($options['curl']['body_as_string']);
37
+ }
38
+
39
+ $easy = new EasyHandle;
40
+ $easy->request = $request;
41
+ $easy->options = $options;
42
+ $conf = $this->getDefaultConf($easy);
43
+ $this->applyMethod($easy, $conf);
44
+ $this->applyHandlerOptions($easy, $conf);
45
+ $this->applyHeaders($easy, $conf);
46
+ unset($conf['_headers']);
47
+
48
+ // Add handler options from the request configuration options
49
+ if (isset($options['curl'])) {
50
+ $conf = array_replace($conf, $options['curl']);
51
+ }
52
+
53
+ $conf[CURLOPT_HEADERFUNCTION] = $this->createHeaderFn($easy);
54
+ $easy->handle = $this->handles
55
+ ? array_pop($this->handles)
56
+ : curl_init();
57
+ curl_setopt_array($easy->handle, $conf);
58
+
59
+ return $easy;
60
+ }
61
+
62
+ public function release(EasyHandle $easy)
63
+ {
64
+ $resource = $easy->handle;
65
+ unset($easy->handle);
66
+
67
+ if (count($this->handles) >= $this->maxHandles) {
68
+ curl_close($resource);
69
+ } else {
70
+ // Remove all callback functions as they can hold onto references
71
+ // and are not cleaned up by curl_reset. Using curl_setopt_array
72
+ // does not work for some reason, so removing each one
73
+ // individually.
74
+ curl_setopt($resource, CURLOPT_HEADERFUNCTION, null);
75
+ curl_setopt($resource, CURLOPT_READFUNCTION, null);
76
+ curl_setopt($resource, CURLOPT_WRITEFUNCTION, null);
77
+ curl_setopt($resource, CURLOPT_PROGRESSFUNCTION, null);
78
+ curl_reset($resource);
79
+ $this->handles[] = $resource;
80
+ }
81
+ }
82
+
83
+ /**
84
+ * Completes a cURL transaction, either returning a response promise or a
85
+ * rejected promise.
86
+ *
87
+ * @param callable $handler
88
+ * @param EasyHandle $easy
89
+ * @param CurlFactoryInterface $factory Dictates how the handle is released
90
+ *
91
+ * @return \GuzzleHttp\Promise\PromiseInterface
92
+ */
93
+ public static function finish(
94
+ callable $handler,
95
+ EasyHandle $easy,
96
+ CurlFactoryInterface $factory
97
+ ) {
98
+ if (isset($easy->options['on_stats'])) {
99
+ self::invokeStats($easy);
100
+ }
101
+
102
+ if (!$easy->response || $easy->errno) {
103
+ return self::finishError($handler, $easy, $factory);
104
+ }
105
+
106
+ // Return the response if it is present and there is no error.
107
+ $factory->release($easy);
108
+
109
+ // Rewind the body of the response if possible.
110
+ $body = $easy->response->getBody();
111
+ if ($body->isSeekable()) {
112
+ $body->rewind();
113
+ }
114
+
115
+ return new FulfilledPromise($easy->response);
116
+ }
117
+
118
+ private static function invokeStats(EasyHandle $easy)
119
+ {
120
+ $curlStats = curl_getinfo($easy->handle);
121
+ $stats = new TransferStats(
122
+ $easy->request,
123
+ $easy->response,
124
+ $curlStats['total_time'],
125
+ $easy->errno,
126
+ $curlStats
127
+ );
128
+ call_user_func($easy->options['on_stats'], $stats);
129
+ }
130
+
131
+ private static function finishError(
132
+ callable $handler,
133
+ EasyHandle $easy,
134
+ CurlFactoryInterface $factory
135
+ ) {
136
+ // Get error information and release the handle to the factory.
137
+ $ctx = [
138
+ 'errno' => $easy->errno,
139
+ 'error' => curl_error($easy->handle),
140
+ ] + curl_getinfo($easy->handle);
141
+ $factory->release($easy);
142
+
143
+ // Retry when nothing is present or when curl failed to rewind.
144
+ if (empty($easy->options['_err_message'])
145
+ && (!$easy->errno || $easy->errno == 65)
146
+ ) {
147
+ return self::retryFailedRewind($handler, $easy, $ctx);
148
+ }
149
+
150
+ return self::createRejection($easy, $ctx);
151
+ }
152
+
153
+ private static function createRejection(EasyHandle $easy, array $ctx)
154
+ {
155
+ static $connectionErrors = [
156
+ CURLE_OPERATION_TIMEOUTED => true,
157
+ CURLE_COULDNT_RESOLVE_HOST => true,
158
+ CURLE_COULDNT_CONNECT => true,
159
+ CURLE_SSL_CONNECT_ERROR => true,
160
+ CURLE_GOT_NOTHING => true,
161
+ ];
162
+
163
+ // If an exception was encountered during the onHeaders event, then
164
+ // return a rejected promise that wraps that exception.
165
+ if ($easy->onHeadersException) {
166
+ return new RejectedPromise(
167
+ new RequestException(
168
+ 'An error was encountered during the on_headers event',
169
+ $easy->request,
170
+ $easy->response,
171
+ $easy->onHeadersException,
172
+ $ctx
173
+ )
174
+ );
175
+ }
176
+
177
+ $message = sprintf(
178
+ 'cURL error %s: %s (%s)',
179
+ $ctx['errno'],
180
+ $ctx['error'],
181
+ 'see http://curl.haxx.se/libcurl/c/libcurl-errors.html'
182
+ );
183
+
184
+ // Create a connection exception if it was a specific error code.
185
+ $error = isset($connectionErrors[$easy->errno])
186
+ ? new ConnectException($message, $easy->request, null, $ctx)
187
+ : new RequestException($message, $easy->request, $easy->response, null, $ctx);
188
+
189
+ return new RejectedPromise($error);
190
+ }
191
+
192
+ private function getDefaultConf(EasyHandle $easy)
193
+ {
194
+ $conf = [
195
+ '_headers' => $easy->request->getHeaders(),
196
+ CURLOPT_CUSTOMREQUEST => $easy->request->getMethod(),
197
+ CURLOPT_URL => (string) $easy->request->getUri(),
198
+ CURLOPT_RETURNTRANSFER => false,
199
+ CURLOPT_HEADER => false,
200
+ CURLOPT_CONNECTTIMEOUT => 150,
201
+ ];
202
+
203
+ if (defined('CURLOPT_PROTOCOLS')) {
204
+ $conf[CURLOPT_PROTOCOLS] = CURLPROTO_HTTP | CURLPROTO_HTTPS;
205
+ }
206
+
207
+ $version = $easy->request->getProtocolVersion();
208
+ if ($version == 1.1) {
209
+ $conf[CURLOPT_HTTP_VERSION] = CURL_HTTP_VERSION_1_1;
210
+ } elseif ($version == 2.0) {
211
+ $conf[CURLOPT_HTTP_VERSION] = CURL_HTTP_VERSION_2_0;
212
+ } else {
213
+ $conf[CURLOPT_HTTP_VERSION] = CURL_HTTP_VERSION_1_0;
214
+ }
215
+
216
+ return $conf;
217
+ }
218
+
219
+ private function applyMethod(EasyHandle $easy, array &$conf)
220
+ {
221
+ $body = $easy->request->getBody();
222
+ $size = $body->getSize();
223
+
224
+ if ($size === null || $size > 0) {
225
+ $this->applyBody($easy->request, $easy->options, $conf);
226
+ return;
227
+ }
228
+
229
+ $method = $easy->request->getMethod();
230
+ if ($method === 'PUT' || $method === 'POST') {
231
+ // See http://tools.ietf.org/html/rfc7230#section-3.3.2
232
+ if (!$easy->request->hasHeader('Content-Length')) {
233
+ $conf[CURLOPT_HTTPHEADER][] = 'Content-Length: 0';
234
+ }
235
+ } elseif ($method === 'HEAD') {
236
+ $conf[CURLOPT_NOBODY] = true;
237
+ unset(
238
+ $conf[CURLOPT_WRITEFUNCTION],
239
+ $conf[CURLOPT_READFUNCTION],
240
+ $conf[CURLOPT_FILE],
241
+ $conf[CURLOPT_INFILE]
242
+ );
243
+ }
244
+ }
245
+
246
+ private function applyBody(RequestInterface $request, array $options, array &$conf)
247
+ {
248
+ $size = $request->hasHeader('Content-Length')
249
+ ? (int) $request->getHeaderLine('Content-Length')
250
+ : null;
251
+
252
+ // Send the body as a string if the size is less than 1MB OR if the
253
+ // [curl][body_as_string] request value is set.
254
+ if (($size !== null && $size < 1000000) ||
255
+ !empty($options['_body_as_string'])
256
+ ) {
257
+ $conf[CURLOPT_POSTFIELDS] = (string) $request->getBody();
258
+ // Don't duplicate the Content-Length header
259
+ $this->removeHeader('Content-Length', $conf);
260
+ $this->removeHeader('Transfer-Encoding', $conf);
261
+ } else {
262
+ $conf[CURLOPT_UPLOAD] = true;
263
+ if ($size !== null) {
264
+ $conf[CURLOPT_INFILESIZE] = $size;
265
+ $this->removeHeader('Content-Length', $conf);
266
+ }
267
+ $body = $request->getBody();
268
+ $conf[CURLOPT_READFUNCTION] = function ($ch, $fd, $length) use ($body) {
269
+ return $body->read($length);
270
+ };
271
+ }
272
+
273
+ // If the Expect header is not present, prevent curl from adding it
274
+ if (!$request->hasHeader('Expect')) {
275
+ $conf[CURLOPT_HTTPHEADER][] = 'Expect:';
276
+ }
277
+
278
+ // cURL sometimes adds a content-type by default. Prevent this.
279
+ if (!$request->hasHeader('Content-Type')) {
280
+ $conf[CURLOPT_HTTPHEADER][] = 'Content-Type:';
281
+ }
282
+ }
283
+
284
+ private function applyHeaders(EasyHandle $easy, array &$conf)
285
+ {
286
+ foreach ($conf['_headers'] as $name => $values) {
287
+ foreach ($values as $value) {
288
+ $conf[CURLOPT_HTTPHEADER][] = "$name: $value";
289
+ }
290
+ }
291
+
292
+ // Remove the Accept header if one was not set
293
+ if (!$easy->request->hasHeader('Accept')) {
294
+ $conf[CURLOPT_HTTPHEADER][] = 'Accept:';
295
+ }
296
+ }
297
+
298
+ /**
299
+ * Remove a header from the options array.
300
+ *
301
+ * @param string $name Case-insensitive header to remove
302
+ * @param array $options Array of options to modify
303
+ */
304
+ private function removeHeader($name, array &$options)
305
+ {
306
+ foreach (array_keys($options['_headers']) as $key) {
307
+ if (!strcasecmp($key, $name)) {
308
+ unset($options['_headers'][$key]);
309
+ return;
310
+ }
311
+ }
312
+ }
313
+
314
+ private function applyHandlerOptions(EasyHandle $easy, array &$conf)
315
+ {
316
+ $options = $easy->options;
317
+ if (isset($options['verify'])) {
318
+ if ($options['verify'] === false) {
319
+ unset($conf[CURLOPT_CAINFO]);
320
+ $conf[CURLOPT_SSL_VERIFYHOST] = 0;
321
+ $conf[CURLOPT_SSL_VERIFYPEER] = false;
322
+ } else {
323
+ $conf[CURLOPT_SSL_VERIFYHOST] = 2;
324
+ $conf[CURLOPT_SSL_VERIFYPEER] = true;
325
+ if (is_string($options['verify'])) {
326
+ $conf[CURLOPT_CAINFO] = $options['verify'];
327
+ if (!file_exists($options['verify'])) {
328
+ throw new \InvalidArgumentException(
329
+ "SSL CA bundle not found: {$options['verify']}"
330
+ );
331
+ }
332
+ }
333
+ }
334
+ }
335
+
336
+ if (!empty($options['decode_content'])) {
337
+ $accept = $easy->request->getHeaderLine('Accept-Encoding');
338
+ if ($accept) {
339
+ $conf[CURLOPT_ENCODING] = $accept;
340
+ } else {
341
+ $conf[CURLOPT_ENCODING] = '';
342
+ // Don't let curl send the header over the wire
343
+ $conf[CURLOPT_HTTPHEADER][] = 'Accept-Encoding:';
344
+ }
345
+ }
346
+
347
+ if (isset($options['sink'])) {
348
+ $sink = $options['sink'];
349
+ if (!is_string($sink)) {
350
+ $sink = \GuzzleHttp\Psr7\stream_for($sink);
351
+ } elseif (!is_dir(dirname($sink))) {
352
+ // Ensure that the directory exists before failing in curl.
353
+ throw new \RuntimeException(sprintf(
354
+ 'Directory %s does not exist for sink value of %s',
355
+ dirname($sink),
356
+ $sink
357
+ ));
358
+ } else {
359
+ $sink = new LazyOpenStream($sink, 'w+');
360
+ }
361
+ $easy->sink = $sink;
362
+ $conf[CURLOPT_WRITEFUNCTION] = function ($ch, $write) use ($sink) {
363
+ return $sink->write($write);
364
+ };
365
+ } else {
366
+ // Use a default temp stream if no sink was set.
367
+ $conf[CURLOPT_FILE] = fopen('php://temp', 'w+');
368
+ $easy->sink = Psr7\stream_for($conf[CURLOPT_FILE]);
369
+ }
370
+
371
+ if (isset($options['timeout'])) {
372
+ $conf[CURLOPT_TIMEOUT_MS] = $options['timeout'] * 1000;
373
+ }
374
+
375
+ if (isset($options['connect_timeout'])) {
376
+ $conf[CURLOPT_CONNECTTIMEOUT_MS] = $options['connect_timeout'] * 1000;
377
+ }
378
+
379
+ if (isset($options['proxy'])) {
380
+ if (!is_array($options['proxy'])) {
381
+ $conf[CURLOPT_PROXY] = $options['proxy'];
382
+ } else {
383
+ $scheme = $easy->request->getUri()->getScheme();
384
+ if (isset($options['proxy'][$scheme])) {
385
+ $host = $easy->request->getUri()->getHost();
386
+ if (!isset($options['proxy']['no']) ||
387
+ !\GuzzleHttp\is_host_in_noproxy($host, $options['proxy']['no'])
388
+ ) {
389
+ $conf[CURLOPT_PROXY] = $options['proxy'][$scheme];
390
+ }
391
+ }
392
+ }
393
+ }
394
+
395
+ if (isset($options['cert'])) {
396
+ $cert = $options['cert'];
397
+ if (is_array($cert)) {
398
+ $conf[CURLOPT_SSLCERTPASSWD] = $cert[1];
399
+ $cert = $cert[0];
400
+ }
401
+ if (!file_exists($cert)) {
402
+ throw new \InvalidArgumentException(
403
+ "SSL certificate not found: {$cert}"
404
+ );
405
+ }
406
+ $conf[CURLOPT_SSLCERT] = $cert;
407
+ }
408
+
409
+ if (isset($options['ssl_key'])) {
410
+ $sslKey = $options['ssl_key'];
411
+ if (is_array($sslKey)) {
412
+ $conf[CURLOPT_SSLKEYPASSWD] = $sslKey[1];
413
+ $sslKey = $sslKey[0];
414
+ }
415
+ if (!file_exists($sslKey)) {
416
+ throw new \InvalidArgumentException(
417
+ "SSL private key not found: {$sslKey}"
418
+ );
419
+ }
420
+ $conf[CURLOPT_SSLKEY] = $sslKey;
421
+ }
422
+
423
+ if (isset($options['progress'])) {
424
+ $progress = $options['progress'];
425
+ if (!is_callable($progress)) {
426
+ throw new \InvalidArgumentException(
427
+ 'progress client option must be callable'
428
+ );
429
+ }
430
+ $conf[CURLOPT_NOPROGRESS] = false;
431
+ $conf[CURLOPT_PROGRESSFUNCTION] = function () use ($progress) {
432
+ $args = func_get_args();
433
+ // PHP 5.5 pushed the handle onto the start of the args
434
+ if (is_resource($args[0])) {
435
+ array_shift($args);
436
+ }
437
+ call_user_func_array($progress, $args);
438
+ };
439
+ }
440
+
441
+ if (!empty($options['debug'])) {
442
+ $conf[CURLOPT_STDERR] = \GuzzleHttp\debug_resource($options['debug']);
443
+ $conf[CURLOPT_VERBOSE] = true;
444
+ }
445
+ }
446
+
447
+ /**
448
+ * This function ensures that a response was set on a transaction. If one
449
+ * was not set, then the request is retried if possible. This error
450
+ * typically means you are sending a payload, curl encountered a
451
+ * "Connection died, retrying a fresh connect" error, tried to rewind the
452
+ * stream, and then encountered a "necessary data rewind wasn't possible"
453
+ * error, causing the request to be sent through curl_multi_info_read()
454
+ * without an error status.
455
+ */
456
+ private static function retryFailedRewind(
457
+ callable $handler,
458
+ EasyHandle $easy,
459
+ array $ctx
460
+ ) {
461
+ try {
462
+ // Only rewind if the body has been read from.
463
+ $body = $easy->request->getBody();
464
+ if ($body->tell() > 0) {
465
+ $body->rewind();
466
+ }
467
+ } catch (\RuntimeException $e) {
468
+ $ctx['error'] = 'The connection unexpectedly failed without '
469
+ . 'providing an error. The request would have been retried, '
470
+ . 'but attempting to rewind the request body failed. '
471
+ . 'Exception: ' . $e;
472
+ return self::createRejection($easy, $ctx);
473
+ }
474
+
475
+ // Retry no more than 3 times before giving up.
476
+ if (!isset($easy->options['_curl_retries'])) {
477
+ $easy->options['_curl_retries'] = 1;
478
+ } elseif ($easy->options['_curl_retries'] == 2) {
479
+ $ctx['error'] = 'The cURL request was retried 3 times '
480
+ . 'and did not succeed. The most likely reason for the failure '
481
+ . 'is that cURL was unable to rewind the body of the request '
482
+ . 'and subsequent retries resulted in the same error. Turn on '
483
+ . 'the debug option to see what went wrong. See '
484
+ . 'https://bugs.php.net/bug.php?id=47204 for more information.';
485
+ return self::createRejection($easy, $ctx);
486
+ } else {
487
+ $easy->options['_curl_retries']++;
488
+ }
489
+
490
+ return $handler($easy->request, $easy->options);
491
+ }
492
+
493
+ private function createHeaderFn(EasyHandle $easy)
494
+ {
495
+ if (!isset($easy->options['on_headers'])) {
496
+ $onHeaders = null;
497
+ } elseif (!is_callable($easy->options['on_headers'])) {
498
+ throw new \InvalidArgumentException('on_headers must be callable');
499
+ } else {
500
+ $onHeaders = $easy->options['on_headers'];
501
+ }
502
+
503
+ return function ($ch, $h) use (
504
+ $onHeaders,
505
+ $easy,
506
+ &$startingResponse
507
+ ) {
508
+ $value = trim($h);
509
+ if ($value === '') {
510
+ $startingResponse = true;
511
+ $easy->createResponse();
512
+ if ($onHeaders) {
513
+ try {
514
+ $onHeaders($easy->response);
515
+ } catch (\Exception $e) {
516
+ // Associate the exception with the handle and trigger
517
+ // a curl header write error by returning 0.
518
+ $easy->onHeadersException = $e;
519
+ return -1;
520
+ }
521
+ }
522
+ } elseif ($startingResponse) {
523
+ $startingResponse = false;
524
+ $easy->headers = [$value];
525
+ } else {
526
+ $easy->headers[] = $value;
527
+ }
528
+ return strlen($h);
529
+ };
530
+ }
531
+ }
app/api/Ctct/vendor/guzzlehttp/guzzle/src/Handler/CurlFactoryInterface.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Handler;
3
+
4
+ use Psr\Http\Message\RequestInterface;
5
+
6
+ interface CurlFactoryInterface
7
+ {
8
+ /**
9
+ * Creates a cURL handle resource.
10
+ *
11
+ * @param RequestInterface $request Request
12
+ * @param array $options Transfer options
13
+ *
14
+ * @return EasyHandle
15
+ * @throws \RuntimeException when an option cannot be applied
16
+ */
17
+ public function create(RequestInterface $request, array $options);
18
+
19
+ /**
20
+ * Release an easy handle, allowing it to be reused or closed.
21
+ *
22
+ * This function must call unset on the easy handle's "handle" property.
23
+ *
24
+ * @param EasyHandle $easy
25
+ */
26
+ public function release(EasyHandle $easy);
27
+ }
app/api/Ctct/vendor/guzzlehttp/guzzle/src/Handler/CurlHandler.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Handler;
3
+
4
+ use GuzzleHttp\Psr7;
5
+ use Psr\Http\Message\RequestInterface;
6
+
7
+ /**
8
+ * HTTP handler that uses cURL easy handles as a transport layer.
9
+ *
10
+ * When using the CurlHandler, custom curl options can be specified as an
11
+ * associative array of curl option constants mapping to values in the
12
+ * **curl** key of the "client" key of the request.
13
+ */
14
+ class CurlHandler
15
+ {
16
+ /** @var CurlFactoryInterface */
17
+ private $factory;
18
+
19
+ /**
20
+ * Accepts an associative array of options:
21
+ *
22
+ * - factory: Optional curl factory used to create cURL handles.
23
+ *
24
+ * @param array $options Array of options to use with the handler
25
+ */
26
+ public function __construct(array $options = [])
27
+ {
28
+ $this->factory = isset($options['handle_factory'])
29
+ ? $options['handle_factory']
30
+ : new CurlFactory(3);
31
+ }
32
+
33
+ public function __invoke(RequestInterface $request, array $options)
34
+ {
35
+ if (isset($options['delay'])) {
36
+ usleep($options['delay'] * 1000);
37
+ }
38
+
39
+ $easy = $this->factory->create($request, $options);
40
+ curl_exec($easy->handle);
41
+ $easy->errno = curl_errno($easy->handle);
42
+
43
+ return CurlFactory::finish($this, $easy, $this->factory);
44
+ }
45
+ }
app/api/Ctct/vendor/guzzlehttp/guzzle/src/Handler/CurlMultiHandler.php ADDED
@@ -0,0 +1,197 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Handler;
3
+
4
+ use GuzzleHttp\Promise as P;
5
+ use GuzzleHttp\Promise\Promise;
6
+ use GuzzleHttp\Psr7;
7
+ use Psr\Http\Message\RequestInterface;
8
+
9
+ /**
10
+ * Returns an asynchronous response using curl_multi_* functions.
11
+ *
12
+ * When using the CurlMultiHandler, custom curl options can be specified as an
13
+ * associative array of curl option constants mapping to values in the
14
+ * **curl** key of the provided request options.
15
+ *
16
+ * @property resource $_mh Internal use only. Lazy loaded multi-handle.
17
+ */
18
+ class CurlMultiHandler
19
+ {
20
+ /** @var CurlFactoryInterface */
21
+ private $factory;
22
+ private $selectTimeout;
23
+ private $active;
24
+ private $handles = [];
25
+ private $delays = [];
26
+
27
+ /**
28
+ * This handler accepts the following options:
29
+ *
30
+ * - handle_factory: An optional factory used to create curl handles
31
+ * - select_timeout: Optional timeout (in seconds) to block before timing
32
+ * out while selecting curl handles. Defaults to 1 second.
33
+ *
34
+ * @param array $options
35
+ */
36
+ public function __construct(array $options = [])
37
+ {
38
+ $this->factory = isset($options['handle_factory'])
39
+ ? $options['handle_factory'] : new CurlFactory(50);
40
+ $this->selectTimeout = isset($options['select_timeout'])
41
+ ? $options['select_timeout'] : 1;
42
+ }
43
+
44
+ public function __get($name)
45
+ {
46
+ if ($name === '_mh') {
47
+ return $this->_mh = curl_multi_init();
48
+ }
49
+
50
+ throw new \BadMethodCallException();
51
+ }
52
+
53
+ public function __destruct()
54
+ {
55
+ if (isset($this->_mh)) {
56
+ curl_multi_close($this->_mh);
57
+ unset($this->_mh);
58
+ }
59
+ }
60
+
61
+ public function __invoke(RequestInterface $request, array $options)
62
+ {
63
+ $easy = $this->factory->create($request, $options);
64
+ $id = (int) $easy->handle;
65
+
66
+ $promise = new Promise(
67
+ [$this, 'execute'],
68
+ function () use ($id) { return $this->cancel($id); }
69
+ );
70
+
71
+ $this->addRequest(['easy' => $easy, 'deferred' => $promise]);
72
+
73
+ return $promise;
74
+ }
75
+
76
+ /**
77
+ * Ticks the curl event loop.
78
+ */
79
+ public function tick()
80
+ {
81
+ // Add any delayed handles if needed.
82
+ if ($this->delays) {
83
+ $currentTime = microtime(true);
84
+ foreach ($this->delays as $id => $delay) {
85
+ if ($currentTime >= $delay) {
86
+ unset($this->delays[$id]);
87
+ curl_multi_add_handle(
88
+ $this->_mh,
89
+ $this->handles[$id]['easy']->handle
90
+ );
91
+ }
92
+ }
93
+ }
94
+
95
+ // Step through the task queue which may add additional requests.
96
+ P\queue()->run();
97
+
98
+ if ($this->active &&
99
+ curl_multi_select($this->_mh, $this->selectTimeout) === -1
100
+ ) {
101
+ // Perform a usleep if a select returns -1.
102
+ // See: https://bugs.php.net/bug.php?id=61141
103
+ usleep(250);
104
+ }
105
+
106
+ while (curl_multi_exec($this->_mh, $this->active) === CURLM_CALL_MULTI_PERFORM);
107
+
108
+ $this->processMessages();
109
+ }
110
+
111
+ /**
112
+ * Runs until all outstanding connections have completed.
113
+ */
114
+ public function execute()
115
+ {
116
+ $queue = P\queue();
117
+
118
+ while ($this->handles || !$queue->isEmpty()) {
119
+ // If there are no transfers, then sleep for the next delay
120
+ if (!$this->active && $this->delays) {
121
+ usleep($this->timeToNext());
122
+ }
123
+ $this->tick();
124
+ }
125
+ }
126
+
127
+ private function addRequest(array $entry)
128
+ {
129
+ $easy = $entry['easy'];
130
+ $id = (int) $easy->handle;
131
+ $this->handles[$id] = $entry;
132
+ if (empty($easy->options['delay'])) {
133
+ curl_multi_add_handle($this->_mh, $easy->handle);
134
+ } else {
135
+ $this->delays[$id] = microtime(true) + ($easy->options['delay'] / 1000);
136
+ }
137
+ }
138
+
139
+ /**
140
+ * Cancels a handle from sending and removes references to it.
141
+ *
142
+ * @param int $id Handle ID to cancel and remove.
143
+ *
144
+ * @return bool True on success, false on failure.
145
+ */
146
+ private function cancel($id)
147
+ {
148
+ // Cannot cancel if it has been processed.
149
+ if (!isset($this->handles[$id])) {
150
+ return false;
151
+ }
152
+
153
+ $handle = $this->handles[$id]['easy']->handle;
154
+ unset($this->delays[$id], $this->handles[$id]);
155
+ curl_multi_remove_handle($this->_mh, $handle);
156
+ curl_close($handle);
157
+
158
+ return true;
159
+ }
160
+
161
+ private function processMessages()
162
+ {
163
+ while ($done = curl_multi_info_read($this->_mh)) {
164
+ $id = (int) $done['handle'];
165
+ curl_multi_remove_handle($this->_mh, $done['handle']);
166
+
167
+ if (!isset($this->handles[$id])) {
168
+ // Probably was cancelled.
169
+ continue;
170
+ }
171
+
172
+ $entry = $this->handles[$id];
173
+ unset($this->handles[$id], $this->delays[$id]);
174
+ $entry['easy']->errno = $done['result'];
175
+ $entry['deferred']->resolve(
176
+ CurlFactory::finish(
177
+ $this,
178
+ $entry['easy'],
179
+ $this->factory
180
+ )
181
+ );
182
+ }
183
+ }
184
+
185
+ private function timeToNext()
186
+ {
187
+ $currentTime = microtime(true);
188
+ $nextTime = PHP_INT_MAX;
189
+ foreach ($this->delays as $time) {
190
+ if ($time < $nextTime) {
191
+ $nextTime = $time;
192
+ }
193
+ }
194
+
195
+ return max(0, $currentTime - $nextTime);
196
+ }
197
+ }
app/api/Ctct/vendor/guzzlehttp/guzzle/src/Handler/EasyHandle.php ADDED
@@ -0,0 +1,87 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Handler;
3
+
4
+ use GuzzleHttp\Psr7\Response;
5
+ use Psr\Http\Message\RequestInterface;
6
+ use Psr\Http\Message\ResponseInterface;
7
+ use Psr\Http\Message\StreamInterface;
8
+
9
+ /**
10
+ * Represents a cURL easy handle and the data it populates.
11
+ *
12
+ * @internal
13
+ */
14
+ final class EasyHandle
15
+ {
16
+ /** @var resource cURL resource */
17
+ public $handle;
18
+
19
+ /** @var StreamInterface Where data is being written */
20
+ public $sink;
21
+
22
+ /** @var array Received HTTP headers so far */
23
+ public $headers = [];
24
+
25
+ /** @var ResponseInterface Received response (if any) */
26
+ public $response;
27
+
28
+ /** @var RequestInterface Request being sent */
29
+ public $request;
30
+
31
+ /** @var array Request options */
32
+ public $options = [];
33
+
34
+ /** @var int cURL error number (if any) */
35
+ public $errno = 0;
36
+
37
+ /** @var \Exception Exception during on_headers (if any) */
38
+ public $onHeadersException;
39
+
40
+ /**
41
+ * Attach a response to the easy handle based on the received headers.
42
+ *
43
+ * @throws \RuntimeException if no headers have been received.
44
+ */
45
+ public function createResponse()
46
+ {
47
+ if (empty($this->headers)) {
48
+ throw new \RuntimeException('No headers have been received');
49
+ }
50
+
51
+ // HTTP-version SP status-code SP reason-phrase
52
+ $startLine = explode(' ', array_shift($this->headers), 3);
53
+ $headers = \GuzzleHttp\headers_from_lines($this->headers);
54
+ $normalizedKeys = \GuzzleHttp\normalize_header_keys($headers);
55
+
56
+ if (!empty($this->options['decode_content'])
57
+ && isset($normalizedKeys['content-encoding'])
58
+ ) {
59
+ unset($headers[$normalizedKeys['content-encoding']]);
60
+ if (isset($normalizedKeys['content-length'])) {
61
+ $bodyLength = (int) $this->sink->getSize();
62
+ if ($bodyLength) {
63
+ $headers[$normalizedKeys['content-length']] = $bodyLength;
64
+ } else {
65
+ unset($headers[$normalizedKeys['content-length']]);
66
+ }
67
+ }
68
+ }
69
+
70
+ // Attach a response to the easy handle with the parsed headers.
71
+ $this->response = new Response(
72
+ $startLine[1],
73
+ $headers,
74
+ $this->sink,
75
+ substr($startLine[0], 5),
76
+ isset($startLine[2]) ? (string) $startLine[2] : null
77
+ );
78
+ }
79
+
80
+ public function __get($name)
81
+ {
82
+ $msg = $name === 'handle'
83
+ ? 'The EasyHandle has been released'
84
+ : 'Invalid property: ' . $name;
85
+ throw new \BadMethodCallException($msg);
86
+ }
87
+ }
app/api/Ctct/vendor/guzzlehttp/guzzle/src/Handler/MockHandler.php ADDED
@@ -0,0 +1,176 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Handler;
3
+
4
+ use GuzzleHttp\HandlerStack;
5
+ use GuzzleHttp\Promise\PromiseInterface;
6
+ use GuzzleHttp\Promise\RejectedPromise;
7
+ use GuzzleHttp\TransferStats;
8
+ use Psr\Http\Message\RequestInterface;
9
+ use Psr\Http\Message\ResponseInterface;
10
+
11
+ /**
12
+ * Handler that returns responses or throw exceptions from a queue.
13
+ */
14
+ class MockHandler implements \Countable
15
+ {
16
+ private $queue;
17
+ private $lastRequest;
18
+ private $lastOptions;
19
+ private $onFulfilled;
20
+ private $onRejected;
21
+
22
+ /**
23
+ * Creates a new MockHandler that uses the default handler stack list of
24
+ * middlewares.
25
+ *
26
+ * @param array $queue Array of responses, callables, or exceptions.
27
+ * @param callable $onFulfilled Callback to invoke when the return value is fulfilled.
28
+ * @param callable $onRejected Callback to invoke when the return value is rejected.
29
+ *
30
+ * @return MockHandler
31
+ */
32
+ public static function createWithMiddleware(
33
+ array $queue = null,
34
+ callable $onFulfilled = null,
35
+ callable $onRejected = null
36
+ ) {
37
+ return HandlerStack::create(new self($queue, $onFulfilled, $onRejected));
38
+ }
39
+
40
+ /**
41
+ * The passed in value must be an array of
42
+ * {@see Psr7\Http\Message\ResponseInterface} objects, Exceptions,
43
+ * callables, or Promises.
44
+ *
45
+ * @param array $queue
46
+ * @param callable $onFulfilled Callback to invoke when the return value is fulfilled.
47
+ * @param callable $onRejected Callback to invoke when the return value is rejected.
48
+ */
49
+ public function __construct(
50
+ array $queue = null,
51
+ callable $onFulfilled = null,
52
+ callable $onRejected = null
53
+ ) {
54
+ $this->onFulfilled = $onFulfilled;
55
+ $this->onRejected = $onRejected;
56
+
57
+ if ($queue) {
58
+ call_user_func_array([$this, 'append'], $queue);
59
+ }
60
+ }
61
+
62
+ public function __invoke(RequestInterface $request, array $options)
63
+ {
64
+ if (!$this->queue) {
65
+ throw new \OutOfBoundsException('Mock queue is empty');
66
+ }
67
+
68
+ if (isset($options['delay'])) {
69
+ usleep($options['delay'] * 1000);
70
+ }
71
+
72
+ $this->lastRequest = $request;
73
+ $this->lastOptions = $options;
74
+ $response = array_shift($this->queue);
75
+
76
+ if (is_callable($response)) {
77
+ $response = $response($request, $options);
78
+ }
79
+
80
+ $response = $response instanceof \Exception
81
+ ? new RejectedPromise($response)
82
+ : \GuzzleHttp\Promise\promise_for($response);
83
+
84
+ return $response->then(
85
+ function ($value) use ($request, $options) {
86
+ $this->invokeStats($request, $options, $value);
87
+ if ($this->onFulfilled) {
88
+ call_user_func($this->onFulfilled, $value);
89
+ }
90
+ if (isset($options['sink'])) {
91
+ $contents = (string) $value->getBody();
92
+ $sink = $options['sink'];
93
+
94
+ if (is_resource($sink)) {
95
+ fwrite($sink, $contents);
96
+ } elseif (is_string($sink)) {
97
+ file_put_contents($sink, $contents);
98
+ } elseif ($sink instanceof \Psr\Http\Message\StreamInterface) {
99
+ $sink->write($contents);
100
+ }
101
+ }
102
+
103
+ return $value;
104
+ },
105
+ function ($reason) use ($request, $options) {
106
+ $this->invokeStats($request, $options, null, $reason);
107
+ if ($this->onRejected) {
108
+ call_user_func($this->onRejected, $reason);
109
+ }
110
+ return new RejectedPromise($reason);
111
+ }
112
+ );
113
+ }
114
+
115
+ /**
116
+ * Adds one or more variadic requests, exceptions, callables, or promises
117
+ * to the queue.
118
+ */
119
+ public function append()
120
+ {
121
+ foreach (func_get_args() as $value) {
122
+ if ($value instanceof ResponseInterface
123
+ || $value instanceof \Exception
124
+ || $value instanceof PromiseInterface
125
+ || is_callable($value)
126
+ ) {
127
+ $this->queue[] = $value;
128
+ } else {
129
+ throw new \InvalidArgumentException('Expected a response or '
130
+ . 'exception. Found ' . \GuzzleHttp\describe_type($value));
131
+ }
132
+ }
133
+ }
134
+
135
+ /**
136
+ * Get the last received request.
137
+ *
138
+ * @return RequestInterface
139
+ */
140
+ public function getLastRequest()
141
+ {
142
+ return $this->lastRequest;
143
+ }
144
+
145
+ /**
146
+ * Get the last received request options.
147
+ *
148
+ * @return RequestInterface
149
+ */
150
+ public function getLastOptions()
151
+ {
152
+ return $this->lastOptions;
153
+ }
154
+
155
+ /**
156
+ * Returns the number of remaining items in the queue.
157
+ *
158
+ * @return int
159
+ */
160
+ public function count()
161
+ {
162
+ return count($this->queue);
163
+ }
164
+
165
+ private function invokeStats(
166
+ RequestInterface $request,
167
+ array $options,
168
+ ResponseInterface $response = null,
169
+ $reason = null
170
+ ) {
171
+ if (isset($options['on_stats'])) {
172
+ $stats = new TransferStats($request, $response, 0, $reason);
173
+ call_user_func($options['on_stats'], $stats);
174
+ }
175
+ }
176
+ }
app/api/Ctct/vendor/guzzlehttp/guzzle/src/Handler/Proxy.php ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Handler;
3
+
4
+ use GuzzleHttp\RequestOptions;
5
+ use Psr\Http\Message\RequestInterface;
6
+
7
+ /**
8
+ * Provides basic proxies for handlers.
9
+ */
10
+ class Proxy
11
+ {
12
+ /**
13
+ * Sends synchronous requests to a specific handler while sending all other
14
+ * requests to another handler.
15
+ *
16
+ * @param callable $default Handler used for normal responses
17
+ * @param callable $sync Handler used for synchronous responses.
18
+ *
19
+ * @return callable Returns the composed handler.
20
+ */
21
+ public static function wrapSync(
22
+ callable $default,
23
+ callable $sync
24
+ ) {
25
+ return function (RequestInterface $request, array $options) use ($default, $sync) {
26
+ return empty($options[RequestOptions::SYNCHRONOUS])
27
+ ? $default($request, $options)
28
+ : $sync($request, $options);
29
+ };
30
+ }
31
+
32
+ /**
33
+ * Sends streaming requests to a streaming compatible handler while sending
34
+ * all other requests to a default handler.
35
+ *
36
+ * This, for example, could be useful for taking advantage of the
37
+ * performance benefits of curl while still supporting true streaming
38
+ * through the StreamHandler.
39
+ *
40
+ * @param callable $default Handler used for non-streaming responses
41
+ * @param callable $streaming Handler used for streaming responses
42
+ *
43
+ * @return callable Returns the composed handler.
44
+ */
45
+ public static function wrapStreaming(
46
+ callable $default,
47
+ callable $streaming
48
+ ) {
49
+ return function (RequestInterface $request, array $options) use ($default, $streaming) {
50
+ return empty($options['stream'])
51
+ ? $default($request, $options)
52
+ : $streaming($request, $options);
53
+ };
54
+ }
55
+ }
app/api/Ctct/vendor/guzzlehttp/guzzle/src/Handler/StreamHandler.php ADDED
@@ -0,0 +1,458 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Handler;
3
+
4
+ use GuzzleHttp\Exception\RequestException;
5
+ use GuzzleHttp\Exception\ConnectException;
6
+ use GuzzleHttp\Promise\FulfilledPromise;
7
+ use GuzzleHttp\Promise\RejectedPromise;
8
+ use GuzzleHttp\Promise\PromiseInterface;
9
+ use GuzzleHttp\Psr7;
10
+ use GuzzleHttp\TransferStats;
11
+ use Psr\Http\Message\RequestInterface;
12
+ use Psr\Http\Message\ResponseInterface;
13
+ use Psr\Http\Message\StreamInterface;
14
+
15
+ /**
16
+ * HTTP handler that uses PHP's HTTP stream wrapper.
17
+ */
18
+ class StreamHandler
19
+ {
20
+ private $lastHeaders = [];
21
+
22
+ /**
23
+ * Sends an HTTP request.
24
+ *
25
+ * @param RequestInterface $request Request to send.
26
+ * @param array $options Request transfer options.
27
+ *
28
+ * @return PromiseInterface
29
+ */
30
+ public function __invoke(RequestInterface $request, array $options)
31
+ {
32
+ // Sleep if there is a delay specified.
33
+ if (isset($options['delay'])) {
34
+ usleep($options['delay'] * 1000);
35
+ }
36
+
37
+ $startTime = isset($options['on_stats']) ? microtime(true) : null;
38
+
39
+ try {
40
+ // Does not support the expect header.
41
+ $request = $request->withoutHeader('Expect');
42
+
43
+ // Append a content-length header if body size is zero to match
44
+ // cURL's behavior.
45
+ if (0 === $request->getBody()->getSize()) {
46
+ $request = $request->withHeader('Content-Length', 0);
47
+ }
48
+
49
+ return $this->createResponse(
50
+ $request,
51
+ $options,
52
+ $this->createStream($request, $options),
53
+ $startTime
54
+ );
55
+ } catch (\InvalidArgumentException $e) {
56
+ throw $e;
57
+ } catch (\Exception $e) {
58
+ // Determine if the error was a networking error.
59
+ $message = $e->getMessage();
60
+ // This list can probably get more comprehensive.
61
+ if (strpos($message, 'getaddrinfo') // DNS lookup failed
62
+ || strpos($message, 'Connection refused')
63
+ || strpos($message, "couldn't connect to host") // error on HHVM
64
+ ) {
65
+ $e = new ConnectException($e->getMessage(), $request, $e);
66
+ }
67
+ $e = RequestException::wrapException($request, $e);
68
+ $this->invokeStats($options, $request, $startTime, null, $e);
69
+
70
+ return new RejectedPromise($e);
71
+ }
72
+ }
73
+
74
+ private function invokeStats(
75
+ array $options,
76
+ RequestInterface $request,
77
+ $startTime,
78
+ ResponseInterface $response = null,
79
+ $error = null
80
+ ) {
81
+ if (isset($options['on_stats'])) {
82
+ $stats = new TransferStats(
83
+ $request,
84
+ $response,
85
+ microtime(true) - $startTime,
86
+ $error,
87
+ []
88
+ );
89
+ call_user_func($options['on_stats'], $stats);
90
+ }
91
+ }
92
+
93
+ private function createResponse(
94
+ RequestInterface $request,
95
+ array $options,
96
+ $stream,
97
+ $startTime
98
+ ) {
99
+ $hdrs = $this->lastHeaders;
100
+ $this->lastHeaders = [];
101
+ $parts = explode(' ', array_shift($hdrs), 3);
102
+ $ver = explode('/', $parts[0])[1];
103
+ $status = $parts[1];
104
+ $reason = isset($parts[2]) ? $parts[2] : null;
105
+ $headers = \GuzzleHttp\headers_from_lines($hdrs);
106
+ list ($stream, $headers) = $this->checkDecode($options, $headers, $stream);
107
+ $stream = Psr7\stream_for($stream);
108
+ $sink = $this->createSink($stream, $options);
109
+ $response = new Psr7\Response($status, $headers, $sink, $ver, $reason);
110
+
111
+ if (isset($options['on_headers'])) {
112
+ try {
113
+ $options['on_headers']($response);
114
+ } catch (\Exception $e) {
115
+ $msg = 'An error was encountered during the on_headers event';
116
+ $ex = new RequestException($msg, $request, $response, $e);
117
+ return new RejectedPromise($ex);
118
+ }
119
+ }
120
+
121
+ if ($sink !== $stream) {
122
+ $this->drain($stream, $sink);
123
+ }
124
+
125
+ $this->invokeStats($options, $request, $startTime, $response, null);
126
+
127
+ return new FulfilledPromise($response);
128
+ }
129
+
130
+ private function createSink(StreamInterface $stream, array $options)
131
+ {
132
+ if (!empty($options['stream'])) {
133
+ return $stream;
134
+ }
135
+
136
+ $sink = isset($options['sink'])
137
+ ? $options['sink']
138
+ : fopen('php://temp', 'r+');
139
+
140
+ return is_string($sink)
141
+ ? new Psr7\Stream(Psr7\try_fopen($sink, 'r+'))
142
+ : Psr7\stream_for($sink);
143
+ }
144
+
145
+ private function checkDecode(array $options, array $headers, $stream)
146
+ {
147
+ // Automatically decode responses when instructed.
148
+ if (!empty($options['decode_content'])) {
149
+ $normalizedKeys = \GuzzleHttp\normalize_header_keys($headers);
150
+ if (isset($normalizedKeys['content-encoding'])) {
151
+ $encoding = $headers[$normalizedKeys['content-encoding']];
152
+ if ($encoding[0] == 'gzip' || $encoding[0] == 'deflate') {
153
+ $stream = new Psr7\InflateStream(
154
+ Psr7\stream_for($stream)
155
+ );
156
+ // Remove content-encoding header
157
+ unset($headers[$normalizedKeys['content-encoding']]);
158
+ // Fix content-length header
159
+ if (isset($normalizedKeys['content-length'])) {
160
+ $length = (int) $stream->getSize();
161
+ if ($length == 0) {
162
+ unset($headers[$normalizedKeys['content-length']]);
163
+ } else {
164
+ $headers[$normalizedKeys['content-length']] = [$length];
165
+ }
166
+ }
167
+ }
168
+ }
169
+ }
170
+
171
+ return [$stream, $headers];
172
+ }
173
+
174
+ /**
175
+ * Drains the source stream into the "sink" client option.
176
+ *
177
+ * @param StreamInterface $source
178
+ * @param StreamInterface $sink
179
+ *
180
+ * @return StreamInterface
181
+ * @throws \RuntimeException when the sink option is invalid.
182
+ */
183
+ private function drain(StreamInterface $source, StreamInterface $sink)
184
+ {
185
+ Psr7\copy_to_stream($source, $sink);
186
+ $sink->seek(0);
187
+ $source->close();
188
+
189
+ return $sink;
190
+ }
191
+
192
+ /**
193
+ * Create a resource and check to ensure it was created successfully
194
+ *
195
+ * @param callable $callback Callable that returns stream resource
196
+ *
197
+ * @return resource
198
+ * @throws \RuntimeException on error
199
+ */
200
+ private function createResource(callable $callback)
201
+ {
202
+ $errors = null;
203
+ set_error_handler(function ($_, $msg, $file, $line) use (&$errors) {
204
+ $errors[] = [
205
+ 'message' => $msg,
206
+ 'file' => $file,
207
+ 'line' => $line
208
+ ];
209
+ return true;
210
+ });
211
+
212
+ $resource = $callback();
213
+ restore_error_handler();
214
+
215
+ if (!$resource) {
216
+ $message = 'Error creating resource: ';
217
+ foreach ($errors as $err) {
218
+ foreach ($err as $key => $value) {
219
+ $message .= "[$key] $value" . PHP_EOL;
220
+ }
221
+ }
222
+ throw new \RuntimeException(trim($message));
223
+ }
224
+
225
+ return $resource;
226
+ }
227
+
228
+ private function createStream(RequestInterface $request, array $options)
229
+ {
230
+ static $methods;
231
+ if (!$methods) {
232
+ $methods = array_flip(get_class_methods(__CLASS__));
233
+ }
234
+
235
+ // HTTP/1.1 streams using the PHP stream wrapper require a
236
+ // Connection: close header
237
+ if ($request->getProtocolVersion() == '1.1'
238
+ && !$request->hasHeader('Connection')
239
+ ) {
240
+ $request = $request->withHeader('Connection', 'close');
241
+ }
242
+
243
+ // Ensure SSL is verified by default
244
+ if (!isset($options['verify'])) {
245
+ $options['verify'] = true;
246
+ }
247
+
248
+ $params = [];
249
+ $context = $this->getDefaultContext($request, $options);
250
+
251
+ if (isset($options['on_headers']) && !is_callable($options['on_headers'])) {
252
+ throw new \InvalidArgumentException('on_headers must be callable');
253
+ }
254
+
255
+ if (!empty($options)) {
256
+ foreach ($options as $key => $value) {
257
+ $method = "add_{$key}";
258
+ if (isset($methods[$method])) {
259
+ $this->{$method}($request, $context, $value, $params);
260
+ }
261
+ }
262
+ }
263
+
264
+ if (isset($options['stream_context'])) {
265
+ if (!is_array($options['stream_context'])) {
266
+ throw new \InvalidArgumentException('stream_context must be an array');
267
+ }
268
+ $context = array_replace_recursive(
269
+ $context,
270
+ $options['stream_context']
271
+ );
272
+ }
273
+
274
+ $context = $this->createResource(
275
+ function () use ($context, $params) {
276
+ return stream_context_create($context, $params);
277
+ }
278
+ );
279
+
280
+ return $this->createResource(
281
+ function () use ($request, &$http_response_header, $context) {
282
+ $resource = fopen($request->getUri(), 'r', null, $context);
283
+ $this->lastHeaders = $http_response_header;
284
+ return $resource;
285
+ }
286
+ );
287
+ }
288
+
289
+ private function getDefaultContext(RequestInterface $request)
290
+ {
291
+ $headers = '';
292
+ foreach ($request->getHeaders() as $name => $value) {
293
+ foreach ($value as $val) {
294
+ $headers .= "$name: $val\r\n";
295
+ }
296
+ }
297
+
298
+ $context = [
299
+ 'http' => [
300
+ 'method' => $request->getMethod(),
301
+ 'header' => $headers,
302
+ 'protocol_version' => $request->getProtocolVersion(),
303
+ 'ignore_errors' => true,
304
+ 'follow_location' => 0,
305
+ ],
306
+ ];
307
+
308
+ $body = (string) $request->getBody();
309
+
310
+ if (!empty($body)) {
311
+ $context['http']['content'] = $body;
312
+ // Prevent the HTTP handler from adding a Content-Type header.
313
+ if (!$request->hasHeader('Content-Type')) {
314
+ $context['http']['header'] .= "Content-Type:\r\n";
315
+ }
316
+ }
317
+
318
+ $context['http']['header'] = rtrim($context['http']['header']);
319
+
320
+ return $context;
321
+ }
322
+
323
+ private function add_proxy(RequestInterface $request, &$options, $value, &$params)
324
+ {
325
+ if (!is_array($value)) {
326
+ $options['http']['proxy'] = $value;
327
+ } else {
328
+ $scheme = $request->getUri()->getScheme();
329
+ if (isset($value[$scheme])) {
330
+ if (!isset($value['no'])
331
+ || !\GuzzleHttp\is_host_in_noproxy(
332
+ $request->getUri()->getHost(),
333
+ $value['no']
334
+ )
335
+ ) {
336
+ $options['http']['proxy'] = $value[$scheme];
337
+ }
338
+ }
339
+ }
340
+ }
341
+
342
+ private function add_timeout(RequestInterface $request, &$options, $value, &$params)
343
+ {
344
+ $options['http']['timeout'] = $value;
345
+ }
346
+
347
+ private function add_verify(RequestInterface $request, &$options, $value, &$params)
348
+ {
349
+ if ($value === true) {
350
+ // PHP 5.6 or greater will find the system cert by default. When
351
+ // < 5.6, use the Guzzle bundled cacert.
352
+ if (PHP_VERSION_ID < 50600) {
353
+ $options['ssl']['cafile'] = \GuzzleHttp\default_ca_bundle();
354
+ }
355
+ } elseif (is_string($value)) {
356
+ $options['ssl']['cafile'] = $value;
357
+ if (!file_exists($value)) {
358
+ throw new \RuntimeException("SSL CA bundle not found: $value");
359
+ }
360
+ } elseif ($value === false) {
361
+ $options['ssl']['verify_peer'] = false;
362
+ $options['ssl']['verify_peer_name'] = false;
363
+ return;
364
+ } else {
365
+ throw new \InvalidArgumentException('Invalid verify request option');
366
+ }
367
+
368
+ $options['ssl']['verify_peer'] = true;
369
+ $options['ssl']['verify_peer_name'] = true;
370
+ $options['ssl']['allow_self_signed'] = false;
371
+ }
372
+
373
+ private function add_cert(RequestInterface $request, &$options, $value, &$params)
374
+ {
375
+ if (is_array($value)) {
376
+ $options['ssl']['passphrase'] = $value[1];
377
+ $value = $value[0];
378
+ }
379
+
380
+ if (!file_exists($value)) {
381
+ throw new \RuntimeException("SSL certificate not found: {$value}");
382
+ }
383
+
384
+ $options['ssl']['local_cert'] = $value;
385
+ }
386
+
387
+ private function add_progress(RequestInterface $request, &$options, $value, &$params)
388
+ {
389
+ $this->addNotification(
390
+ $params,
391
+ function ($code, $a, $b, $c, $transferred, $total) use ($value) {
392
+ if ($code == STREAM_NOTIFY_PROGRESS) {
393
+ $value($total, $transferred, null, null);
394
+ }
395
+ }
396
+ );
397
+ }
398
+
399
+ private function add_debug(RequestInterface $request, &$options, $value, &$params)
400
+ {
401
+ if ($value === false) {
402
+ return;
403
+ }
404
+
405
+ static $map = [
406
+ STREAM_NOTIFY_CONNECT => 'CONNECT',
407
+ STREAM_NOTIFY_AUTH_REQUIRED => 'AUTH_REQUIRED',
408
+ STREAM_NOTIFY_AUTH_RESULT => 'AUTH_RESULT',
409
+ STREAM_NOTIFY_MIME_TYPE_IS => 'MIME_TYPE_IS',
410
+ STREAM_NOTIFY_FILE_SIZE_IS => 'FILE_SIZE_IS',
411
+ STREAM_NOTIFY_REDIRECTED => 'REDIRECTED',
412
+ STREAM_NOTIFY_PROGRESS => 'PROGRESS',
413
+ STREAM_NOTIFY_FAILURE => 'FAILURE',
414
+ STREAM_NOTIFY_COMPLETED => 'COMPLETED',
415
+ STREAM_NOTIFY_RESOLVE => 'RESOLVE',
416
+ ];
417
+ static $args = ['severity', 'message', 'message_code',
418
+ 'bytes_transferred', 'bytes_max'];
419
+
420
+ $value = \GuzzleHttp\debug_resource($value);
421
+ $ident = $request->getMethod() . ' ' . $request->getUri();
422
+ $this->addNotification(
423
+ $params,
424
+ function () use ($ident, $value, $map, $args) {
425
+ $passed = func_get_args();
426
+ $code = array_shift($passed);
427
+ fprintf($value, '<%s> [%s] ', $ident, $map[$code]);
428
+ foreach (array_filter($passed) as $i => $v) {
429
+ fwrite($value, $args[$i] . ': "' . $v . '" ');
430
+ }
431
+ fwrite($value, "\n");
432
+ }
433
+ );
434
+ }
435
+
436
+ private function addNotification(array &$params, callable $notify)
437
+ {
438
+ // Wrap the existing function if needed.
439
+ if (!isset($params['notification'])) {
440
+ $params['notification'] = $notify;
441
+ } else {
442
+ $params['notification'] = $this->callArray([
443
+ $params['notification'],
444
+ $notify
445
+ ]);
446
+ }
447
+ }
448
+
449
+ private function callArray(array $functions)
450
+ {
451
+ return function () use ($functions) {
452
+ $args = func_get_args();
453
+ foreach ($functions as $fn) {
454
+ call_user_func_array($fn, $args);
455
+ }
456
+ };
457
+ }
458
+ }
app/api/Ctct/vendor/guzzlehttp/guzzle/src/HandlerStack.php ADDED
@@ -0,0 +1,273 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp;
3
+
4
+ use Psr\Http\Message\RequestInterface;
5
+
6
+ /**
7
+ * Creates a composed Guzzle handler function by stacking middlewares on top of
8
+ * an HTTP handler function.
9
+ */
10
+ class HandlerStack
11
+ {
12
+ /** @var callable */
13
+ private $handler;
14
+
15
+ /** @var array */
16
+ private $stack = [];
17
+
18
+ /** @var callable|null */
19
+ private $cached;
20
+
21
+ /**
22
+ * Creates a default handler stack that can be used by clients.
23
+ *
24
+ * The returned handler will wrap the provided handler or use the most
25
+ * appropriate default handler for you system. The returned HandlerStack has
26
+ * support for cookies, redirects, HTTP error exceptions, and preparing a body
27
+ * before sending.
28
+ *
29
+ * The returned handler stack can be passed to a client in the "handler"
30
+ * option.
31
+ *
32
+ * @param callable $handler HTTP handler function to use with the stack. If no
33
+ * handler is provided, the best handler for your
34
+ * system will be utilized.
35
+ *
36
+ * @return HandlerStack
37
+ */
38
+ public static function create(callable $handler = null)
39
+ {
40
+ $stack = new self($handler ?: choose_handler());
41
+ $stack->push(Middleware::httpErrors(), 'http_errors');
42
+ $stack->push(Middleware::redirect(), 'allow_redirects');
43
+ $stack->push(Middleware::cookies(), 'cookies');
44
+ $stack->push(Middleware::prepareBody(), 'prepare_body');
45
+
46
+ return $stack;
47
+ }
48
+
49
+ /**
50
+ * @param callable $handler Underlying HTTP handler.
51
+ */
52
+ public function __construct(callable $handler = null)
53
+ {
54
+ $this->handler = $handler;
55
+ }
56
+
57
+ /**
58
+ * Invokes the handler stack as a composed handler
59
+ *
60
+ * @param RequestInterface $request
61
+ * @param array $options
62
+ */
63
+ public function __invoke(RequestInterface $request, array $options)
64
+ {
65
+ $handler = $this->resolve();
66
+
67
+ return $handler($request, $options);
68
+ }
69
+
70
+ /**
71
+ * Dumps a string representation of the stack.
72
+ *
73
+ * @return string
74
+ */
75
+ public function __toString()
76
+ {
77
+ $depth = 0;
78
+ $stack = [];
79
+ if ($this->handler) {
80
+ $stack[] = "0) Handler: " . $this->debugCallable($this->handler);
81
+ }
82
+
83
+ $result = '';
84
+ foreach (array_reverse($this->stack) as $tuple) {
85
+ $depth++;
86
+ $str = "{$depth}) Name: '{$tuple[1]}', ";
87
+ $str .= "Function: " . $this->debugCallable($tuple[0]);
88
+ $result = "> {$str}\n{$result}";
89
+ $stack[] = $str;
90
+ }
91
+
92
+ foreach (array_keys($stack) as $k) {
93
+ $result .= "< {$stack[$k]}\n";
94
+ }
95
+
96
+ return $result;
97
+ }
98
+
99
+ /**
100
+ * Set the HTTP handler that actually returns a promise.
101
+ *
102
+ * @param callable $handler Accepts a request and array of options and
103
+ * returns a Promise.
104
+ */
105
+ public function setHandler(callable $handler)
106
+ {
107
+ $this->handler = $handler;
108
+ $this->cached = null;
109
+ }
110
+
111
+ /**
112
+ * Returns true if the builder has a handler.
113
+ *
114
+ * @return bool
115
+ */
116
+ public function hasHandler()
117
+ {
118
+ return (bool) $this->handler;
119
+ }
120
+
121
+ /**
122
+ * Unshift a middleware to the bottom of the stack.
123
+ *
124
+ * @param callable $middleware Middleware function
125
+ * @param string $name Name to register for this middleware.
126
+ */
127
+ public function unshift(callable $middleware, $name = null)
128
+ {
129
+ array_unshift($this->stack, [$middleware, $name]);
130
+ $this->cached = null;
131
+ }
132
+
133
+ /**
134
+ * Push a middleware to the top of the stack.
135
+ *
136
+ * @param callable $middleware Middleware function
137
+ * @param string $name Name to register for this middleware.
138
+ */
139
+ public function push(callable $middleware, $name = '')
140
+ {
141
+ $this->stack[] = [$middleware, $name];
142
+ $this->cached = null;
143
+ }
144
+
145
+ /**
146
+ * Add a middleware before another middleware by name.
147
+ *
148
+ * @param string $findName Middleware to find
149
+ * @param callable $middleware Middleware function
150
+ * @param string $withName Name to register for this middleware.
151
+ */
152
+ public function before($findName, callable $middleware, $withName = '')
153
+ {
154
+ $this->splice($findName, $withName, $middleware, true);
155
+ }
156
+
157
+ /**
158
+ * Add a middleware after another middleware by name.
159
+ *
160
+ * @param string $findName Middleware to find
161
+ * @param callable $middleware Middleware function
162
+ * @param string $withName Name to register for this middleware.
163
+ */
164
+ public function after($findName, callable $middleware, $withName = '')
165
+ {
166
+ $this->splice($findName, $withName, $middleware, false);
167
+ }
168
+
169
+ /**
170
+ * Remove a middleware by instance or name from the stack.
171
+ *
172
+ * @param callable|string $remove Middleware to remove by instance or name.
173
+ */
174
+ public function remove($remove)
175
+ {
176
+ $this->cached = null;
177
+ $idx = is_callable($remove) ? 0 : 1;
178
+ $this->stack = array_values(array_filter(
179
+ $this->stack,
180
+ function ($tuple) use ($idx, $remove) {
181
+ return $tuple[$idx] !== $remove;
182
+ }
183
+ ));
184
+ }
185
+
186
+ /**
187
+ * Compose the middleware and handler into a single callable function.
188
+ *
189
+ * @return callable
190
+ */
191
+ public function resolve()
192
+ {
193
+ if (!$this->cached) {
194
+ if (!($prev = $this->handler)) {
195
+ throw new \LogicException('No handler has been specified');
196
+ }
197
+
198
+ foreach (array_reverse($this->stack) as $fn) {
199
+ $prev = $fn[0]($prev);
200
+ }
201
+
202
+ $this->cached = $prev;
203
+ }
204
+
205
+ return $this->cached;
206
+ }
207
+
208
+ /**
209
+ * @param $name
210
+ * @return int
211
+ */
212
+ private function findByName($name)
213
+ {
214
+ foreach ($this->stack as $k => $v) {
215
+ if ($v[1] === $name) {
216
+ return $k;
217
+ }
218
+ }
219
+
220
+ throw new \InvalidArgumentException("Middleware not found: $name");
221
+ }
222
+
223
+ /**
224
+ * Splices a function into the middleware list at a specific position.
225
+ *
226
+ * @param $findName
227
+ * @param $withName
228
+ * @param callable $middleware
229
+ * @param $before
230
+ */
231
+ private function splice($findName, $withName, callable $middleware, $before)
232
+ {
233
+ $this->cached = null;
234
+ $idx = $this->findByName($findName);
235
+ $tuple = [$middleware, $withName];
236
+
237
+ if ($before) {
238
+ if ($idx === 0) {
239
+ array_unshift($this->stack, $tuple);
240
+ } else {
241
+ $replacement = [$tuple, $this->stack[$idx]];
242
+ array_splice($this->stack, $idx, 1, $replacement);
243
+ }
244
+ } elseif ($idx === count($this->stack) - 1) {
245
+ $this->stack[] = $tuple;
246
+ } else {
247
+ $replacement = [$this->stack[$idx], $tuple];
248
+ array_splice($this->stack, $idx, 1, $replacement);
249
+ }
250
+ }
251
+
252
+ /**
253
+ * Provides a debug string for a given callable.
254
+ *
255
+ * @param array|callable $fn Function to write as a string.
256
+ *
257
+ * @return string
258
+ */
259
+ private function debugCallable($fn)
260
+ {
261
+ if (is_string($fn)) {
262
+ return "callable({$fn})";
263
+ }
264
+
265
+ if (is_array($fn)) {
266
+ return is_string($fn[0])
267
+ ? "callable({$fn[0]}::{$fn[1]})"
268
+ : "callable(['" . get_class($fn[0]) . "', '{$fn[1]}'])";
269
+ }
270
+
271
+ return 'callable(' . spl_object_hash($fn) . ')';
272
+ }
273
+ }
app/api/Ctct/vendor/guzzlehttp/guzzle/src/MessageFormatter.php ADDED
@@ -0,0 +1,182 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp;
3
+
4
+ use Psr\Http\Message\MessageInterface;
5
+ use Psr\Http\Message\RequestInterface;
6
+ use Psr\Http\Message\ResponseInterface;
7
+
8
+ /**
9
+ * Formats log messages using variable substitutions for requests, responses,
10
+ * and other transactional data.
11
+ *
12
+ * The following variable substitutions are supported:
13
+ *
14
+ * - {request}: Full HTTP request message
15
+ * - {response}: Full HTTP response message
16
+ * - {ts}: ISO 8601 date in GMT
17
+ * - {date_iso_8601} ISO 8601 date in GMT
18
+ * - {date_common_log} Apache common log date using the configured timezone.
19
+ * - {host}: Host of the request
20
+ * - {method}: Method of the request
21
+ * - {uri}: URI of the request
22
+ * - {host}: Host of the request
23
+ * - {version}: Protocol version
24
+ * - {target}: Request target of the request (path + query + fragment)
25
+ * - {hostname}: Hostname of the machine that sent the request
26
+ * - {code}: Status code of the response (if available)
27
+ * - {phrase}: Reason phrase of the response (if available)
28
+ * - {error}: Any error messages (if available)
29
+ * - {req_header_*}: Replace `*` with the lowercased name of a request header to add to the message
30
+ * - {res_header_*}: Replace `*` with the lowercased name of a response header to add to the message
31
+ * - {req_headers}: Request headers
32
+ * - {res_headers}: Response headers
33
+ * - {req_body}: Request body
34
+ * - {res_body}: Response body
35
+ */
36
+ class MessageFormatter
37
+ {
38
+ /**
39
+ * Apache Common Log Format.
40
+ * @link http://httpd.apache.org/docs/2.4/logs.html#common
41
+ * @var string
42
+ */
43
+ const CLF = "{hostname} {req_header_User-Agent} - [{date_common_log}] \"{method} {target} HTTP/{version}\" {code} {res_header_Content-Length}";
44
+ const DEBUG = ">>>>>>>>\n{request}\n<<<<<<<<\n{response}\n--------\n{error}";
45
+ const SHORT = '[{ts}] "{method} {target} HTTP/{version}" {code}';
46
+
47
+ /** @var string Template used to format log messages */
48
+ private $template;
49
+
50
+ /**
51
+ * @param string $template Log message template
52
+ */
53
+ public function __construct($template = self::CLF)
54
+ {
55
+ $this->template = $template ?: self::CLF;
56
+ }
57
+
58
+ /**
59
+ * Returns a formatted message string.
60
+ *
61
+ * @param RequestInterface $request Request that was sent
62
+ * @param ResponseInterface $response Response that was received
63
+ * @param \Exception $error Exception that was received
64
+ *
65
+ * @return string
66
+ */
67
+ public function format(
68
+ RequestInterface $request,
69
+ ResponseInterface $response = null,
70
+ \Exception $error = null
71
+ ) {
72
+ $cache = [];
73
+
74
+ return preg_replace_callback(
75
+ '/{\s*([A-Za-z_\-\.0-9]+)\s*}/',
76
+ function (array $matches) use ($request, $response, $error, &$cache) {
77
+
78
+ if (isset($cache[$matches[1]])) {
79
+ return $cache[$matches[1]];
80
+ }
81
+
82
+ $result = '';
83
+ switch ($matches[1]) {
84
+ case 'request':
85
+ $result = Psr7\str($request);
86
+ break;
87
+ case 'response':
88
+ $result = $response ? Psr7\str($response) : '';
89
+ break;
90
+ case 'req_headers':
91
+ $result = trim($request->getMethod()
92
+ . ' ' . $request->getRequestTarget())
93
+ . ' HTTP/' . $request->getProtocolVersion() . "\r\n"
94
+ . $this->headers($request);
95
+ break;
96
+ case 'res_headers':
97
+ $result = $response ?
98
+ sprintf(
99
+ 'HTTP/%s %d %s',
100
+ $response->getProtocolVersion(),
101
+ $response->getStatusCode(),
102
+ $response->getReasonPhrase()
103
+ ) . "\r\n" . $this->headers($response)
104
+ : 'NULL';
105
+ break;
106
+ case 'req_body':
107
+ $result = $request->getBody();
108
+ break;
109
+ case 'res_body':
110
+ $result = $response ? $response->getBody() : 'NULL';
111
+ break;
112
+ case 'ts':
113
+ case 'date_iso_8601':
114
+ $result = gmdate('c');
115
+ break;
116
+ case 'date_common_log':
117
+ $result = date('d/M/Y:H:i:s O');
118
+ break;
119
+ case 'method':
120
+ $result = $request->getMethod();
121
+ break;
122
+ case 'version':
123
+ $result = $request->getProtocolVersion();
124
+ break;
125
+ case 'uri':
126
+ case 'url':
127
+ $result = $request->getUri();
128
+ break;
129
+ case 'target':
130
+ $result = $request->getRequestTarget();
131
+ break;
132
+ case 'req_version':
133
+ $result = $request->getProtocolVersion();
134
+ break;
135
+ case 'res_version':
136
+ $result = $response
137
+ ? $response->getProtocolVersion()
138
+ : 'NULL';
139
+ break;
140
+ case 'host':
141
+ $result = $request->getHeaderLine('Host');
142
+ break;
143
+ case 'hostname':
144
+ $result = gethostname();
145
+ break;
146
+ case 'code':
147
+ $result = $response ? $response->getStatusCode() : 'NULL';
148
+ break;
149
+ case 'phrase':
150
+ $result = $response ? $response->getReasonPhrase() : 'NULL';
151
+ break;
152
+ case 'error':
153
+ $result = $error ? $error->getMessage() : 'NULL';
154
+ break;
155
+ default:
156
+ // handle prefixed dynamic headers
157
+ if (strpos($matches[1], 'req_header_') === 0) {
158
+ $result = $request->getHeaderLine(substr($matches[1], 11));
159
+ } elseif (strpos($matches[1], 'res_header_') === 0) {
160
+ $result = $response
161
+ ? $response->getHeaderLine(substr($matches[1], 11))
162
+ : 'NULL';
163
+ }
164
+ }
165
+
166
+ $cache[$matches[1]] = $result;
167
+ return $result;
168
+ },
169
+ $this->template
170
+ );
171
+ }
172
+
173
+ private function headers(MessageInterface $message)
174
+ {
175
+ $result = '';
176
+ foreach ($message->getHeaders() as $name => $values) {
177
+ $result .= $name . ': ' . implode(', ', $values) . "\r\n";
178
+ }
179
+
180
+ return trim($result);
181
+ }
182
+ }
app/api/Ctct/vendor/guzzlehttp/guzzle/src/Middleware.php ADDED
@@ -0,0 +1,249 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp;
3
+
4
+ use GuzzleHttp\Cookie\CookieJarInterface;
5
+ use GuzzleHttp\Exception\RequestException;
6
+ use GuzzleHttp\Promise\RejectedPromise;
7
+ use GuzzleHttp\Psr7;
8
+ use Psr\Http\Message\ResponseInterface;
9
+ use Psr\Log\LoggerInterface;
10
+ use Psr\Log\LogLevel;
11
+
12
+ /**
13
+ * Functions used to create and wrap handlers with handler middleware.
14
+ */
15
+ final class Middleware
16
+ {
17
+ /**
18
+ * Middleware that adds cookies to requests.
19
+ *
20
+ * The options array must be set to a CookieJarInterface in order to use
21
+ * cookies. This is typically handled for you by a client.
22
+ *
23
+ * @return callable Returns a function that accepts the next handler.
24
+ */
25
+ public static function cookies()
26
+ {
27
+ return function (callable $handler) {
28
+ return function ($request, array $options) use ($handler) {
29
+ if (empty($options['cookies'])) {
30
+ return $handler($request, $options);
31
+ } elseif (!($options['cookies'] instanceof CookieJarInterface)) {
32
+ throw new \InvalidArgumentException('cookies must be an instance of GuzzleHttp\Cookie\CookieJarInterface');
33
+ }
34
+ $cookieJar = $options['cookies'];
35
+ $request = $cookieJar->withCookieHeader($request);
36
+ return $handler($request, $options)
37
+ ->then(function ($response) use ($cookieJar, $request) {
38
+ $cookieJar->extractCookies($request, $response);
39
+ return $response;
40
+ }
41
+ );
42
+ };
43
+ };
44
+ }
45
+
46
+ /**
47
+ * Middleware that throws exceptions for 4xx or 5xx responses when the
48
+ * "http_error" request option is set to true.
49
+ *
50
+ * @return callable Returns a function that accepts the next handler.
51
+ */
52
+ public static function httpErrors()
53
+ {
54
+ return function (callable $handler) {
55
+ return function ($request, array $options) use ($handler) {
56
+ if (empty($options['http_errors'])) {
57
+ return $handler($request, $options);
58
+ }
59
+ return $handler($request, $options)->then(
60
+ function (ResponseInterface $response) use ($request, $handler) {
61
+ $code = $response->getStatusCode();
62
+ if ($code < 400) {
63
+ return $response;
64
+ }
65
+ throw RequestException::create($request, $response);
66
+ }
67
+ );
68
+ };
69
+ };
70
+ }
71
+
72
+ /**
73
+ * Middleware that pushes history data to an ArrayAccess container.
74
+ *
75
+ * @param array $container Container to hold the history (by reference).
76
+ *
77
+ * @return callable Returns a function that accepts the next handler.
78
+ */
79
+ public static function history(array &$container)
80
+ {
81
+ return function (callable $handler) use (&$container) {
82
+ return function ($request, array $options) use ($handler, &$container) {
83
+ return $handler($request, $options)->then(
84
+ function ($value) use ($request, &$container, $options) {
85
+ $container[] = [
86
+ 'request' => $request,
87
+ 'response' => $value,
88
+ 'error' => null,
89
+ 'options' => $options
90
+ ];
91
+ return $value;
92
+ },
93
+ function ($reason) use ($request, &$container, $options) {
94
+ $container[] = [
95
+ 'request' => $request,
96
+ 'response' => null,
97
+ 'error' => $reason,
98
+ 'options' => $options
99
+ ];
100
+ return new RejectedPromise($reason);
101
+ }
102
+ );
103
+ };
104
+ };
105
+ }
106
+
107
+ /**
108
+ * Middleware that invokes a callback before and after sending a request.
109
+ *
110
+ * The provided listener cannot modify or alter the response. It simply
111
+ * "taps" into the chain to be notified before returning the promise. The
112
+ * before listener accepts a request and options array, and the after
113
+ * listener accepts a request, options array, and response promise.
114
+ *
115
+ * @param callable $before Function to invoke before forwarding the request.
116
+ * @param callable $after Function invoked after forwarding.
117
+ *
118
+ * @return callable Returns a function that accepts the next handler.
119
+ */
120
+ public static function tap(callable $before = null, callable $after = null)
121
+ {
122
+ return function (callable $handler) use ($before, $after) {
123
+ return function ($request, array $options) use ($handler, $before, $after) {
124
+ if ($before) {
125
+ $before($request, $options);
126
+ }
127
+ $response = $handler($request, $options);
128
+ if ($after) {
129
+ $after($request, $options, $response);
130
+ }
131
+ return $response;
132
+ };
133
+ };
134
+ }
135
+
136
+ /**
137
+ * Middleware that handles request redirects.
138
+ *
139
+ * @return callable Returns a function that accepts the next handler.
140
+ */
141
+ public static function redirect()
142
+ {
143
+ return function (callable $handler) {
144
+ return new RedirectMiddleware($handler);
145
+ };
146
+ }
147
+
148
+ /**
149
+ * Middleware that retries requests based on the boolean result of
150
+ * invoking the provided "decider" function.
151
+ *
152
+ * If no delay function is provided, a simple implementation of exponential
153
+ * backoff will be utilized.
154
+ *
155
+ * @param callable $decider Function that accepts the number of retries,
156
+ * a request, [response], and [exception] and
157
+ * returns true if the request is to be retried.
158
+ * @param callable $delay Function that accepts the number of retries and
159
+ * returns the number of milliseconds to delay.
160
+ *
161
+ * @return callable Returns a function that accepts the next handler.
162
+ */
163
+ public static function retry(callable $decider, callable $delay = null)
164
+ {
165
+ return function (callable $handler) use ($decider, $delay) {
166
+ return new RetryMiddleware($decider, $handler, $delay);
167
+ };
168
+ }
169
+
170
+ /**
171
+ * Middleware that logs requests, responses, and errors using a message
172
+ * formatter.
173
+ *
174
+ * @param LoggerInterface $logger Logs messages.
175
+ * @param MessageFormatter $formatter Formatter used to create message strings.
176
+ * @param string $logLevel Level at which to log requests.
177
+ *
178
+ * @return callable Returns a function that accepts the next handler.
179
+ */
180
+ public static function log(LoggerInterface $logger, MessageFormatter $formatter, $logLevel = LogLevel::INFO)
181
+ {
182
+ return function (callable $handler) use ($logger, $formatter, $logLevel) {
183
+ return function ($request, array $options) use ($handler, $logger, $formatter, $logLevel) {
184
+ return $handler($request, $options)->then(
185
+ function ($response) use ($logger, $request, $formatter, $logLevel) {
186
+ $message = $formatter->format($request, $response);
187
+ $logger->log($logLevel, $message);
188
+ return $response;
189
+ },
190
+ function ($reason) use ($logger, $request, $formatter) {
191
+ $response = $reason instanceof RequestException
192
+ ? $reason->getResponse()
193
+ : null;
194
+ $message = $formatter->format($request, $response, $reason);
195
+ $logger->notice($message);
196
+ return \GuzzleHttp\Promise\rejection_for($reason);
197
+ }
198
+ );
199
+ };
200
+ };
201
+ }
202
+
203
+ /**
204
+ * This middleware adds a default content-type if possible, a default
205
+ * content-length or transfer-encoding header, and the expect header.
206
+ *
207
+ * @return callable
208
+ */
209
+ public static function prepareBody()
210
+ {
211
+ return function (callable $handler) {
212
+ return new PrepareBodyMiddleware($handler);
213
+ };
214
+ }
215
+
216
+ /**
217
+ * Middleware that applies a map function to the request before passing to
218
+ * the next handler.
219
+ *
220
+ * @param callable $fn Function that accepts a RequestInterface and returns
221
+ * a RequestInterface.
222
+ * @return callable
223
+ */
224
+ public static function mapRequest(callable $fn)
225
+ {
226
+ return function (callable $handler) use ($fn) {
227
+ return function ($request, array $options) use ($handler, $fn) {
228
+ return $handler($fn($request), $options);
229
+ };
230
+ };
231
+ }
232
+
233
+ /**
234
+ * Middleware that applies a map function to the resolved promise's
235
+ * response.
236
+ *
237
+ * @param callable $fn Function that accepts a ResponseInterface and
238
+ * returns a ResponseInterface.
239
+ * @return callable
240
+ */
241
+ public static function mapResponse(callable $fn)
242
+ {
243
+ return function (callable $handler) use ($fn) {
244
+ return function ($request, array $options) use ($handler, $fn) {
245
+ return $handler($request, $options)->then($fn);
246
+ };
247
+ };
248
+ }
249
+ }
app/api/Ctct/vendor/guzzlehttp/guzzle/src/Pool.php ADDED
@@ -0,0 +1,123 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp;
3
+
4
+ use GuzzleHttp\Promise\PromisorInterface;
5
+ use Psr\Http\Message\RequestInterface;
6
+ use GuzzleHttp\Promise\EachPromise;
7
+
8
+ /**
9
+ * Sends and iterator of requests concurrently using a capped pool size.
10
+ *
11
+ * The pool will read from an iterator until it is cancelled or until the
12
+ * iterator is consumed. When a request is yielded, the request is sent after
13
+ * applying the "request_options" request options (if provided in the ctor).
14
+ *
15
+ * When a function is yielded by the iterator, the function is provided the
16
+ * "request_options" array that should be merged on top of any existing
17
+ * options, and the function MUST then return a wait-able promise.
18
+ */
19
+ class Pool implements PromisorInterface
20
+ {
21
+ /** @var EachPromise */
22
+ private $each;
23
+
24
+ /**
25
+ * @param ClientInterface $client Client used to send the requests.
26
+ * @param array|\Iterator $requests Requests or functions that return
27
+ * requests to send concurrently.
28
+ * @param array $config Associative array of options
29
+ * - concurrency: (int) Maximum number of requests to send concurrently
30
+ * - options: Array of request options to apply to each request.
31
+ * - fulfilled: (callable) Function to invoke when a request completes.
32
+ * - rejected: (callable) Function to invoke when a request is rejected.
33
+ */
34
+ public function __construct(
35
+ ClientInterface $client,
36
+ $requests,
37
+ array $config = []
38
+ ) {
39
+ // Backwards compatibility.
40
+ if (isset($config['pool_size'])) {
41
+ $config['concurrency'] = $config['pool_size'];
42
+ } elseif (!isset($config['concurrency'])) {
43
+ $config['concurrency'] = 25;
44
+ }
45
+
46
+ if (isset($config['options'])) {
47
+ $opts = $config['options'];
48
+ unset($config['options']);
49
+ } else {
50
+ $opts = [];
51
+ }
52
+
53
+ $iterable = \GuzzleHttp\Promise\iter_for($requests);
54
+ $requests = function () use ($iterable, $client, $opts) {
55
+ foreach ($iterable as $key => $rfn) {
56
+ if ($rfn instanceof RequestInterface) {
57
+ yield $key => $client->sendAsync($rfn, $opts);
58
+ } elseif (is_callable($rfn)) {
59
+ yield $key => $rfn($opts);
60
+ } else {
61
+ throw new \InvalidArgumentException('Each value yielded by '
62
+ . 'the iterator must be a Psr7\Http\Message\RequestInterface '
63
+ . 'or a callable that returns a promise that fulfills '
64
+ . 'with a Psr7\Message\Http\ResponseInterface object.');
65
+ }
66
+ }
67
+ };
68
+
69
+ $this->each = new EachPromise($requests(), $config);
70
+ }
71
+
72
+ public function promise()
73
+ {
74
+ return $this->each->promise();
75
+ }
76
+
77
+ /**
78
+ * Sends multiple requests concurrently and returns an array of responses
79
+ * and exceptions that uses the same ordering as the provided requests.
80
+ *
81
+ * IMPORTANT: This method keeps every request and response in memory, and
82
+ * as such, is NOT recommended when sending a large number or an
83
+ * indeterminate number of requests concurrently.
84
+ *
85
+ * @param ClientInterface $client Client used to send the requests
86
+ * @param array|\Iterator $requests Requests to send concurrently.
87
+ * @param array $options Passes through the options available in
88
+ * {@see GuzzleHttp\Pool::__construct}
89
+ *
90
+ * @return array Returns an array containing the response or an exception
91
+ * in the same order that the requests were sent.
92
+ * @throws \InvalidArgumentException if the event format is incorrect.
93
+ */
94
+ public static function batch(
95
+ ClientInterface $client,
96
+ $requests,
97
+ array $options = []
98
+ ) {
99
+ $res = [];
100
+ self::cmpCallback($options, 'fulfilled', $res);
101
+ self::cmpCallback($options, 'rejected', $res);
102
+ $pool = new static($client, $requests, $options);
103
+ $pool->promise()->wait();
104
+ ksort($res);
105
+
106
+ return $res;
107
+ }
108
+
109
+ private static function cmpCallback(array &$options, $name, array &$results)
110
+ {
111
+ if (!isset($options[$name])) {
112
+ $options[$name] = function ($v, $k) use (&$results) {
113
+ $results[$k] = $v;
114
+ };
115
+ } else {
116
+ $currentFn = $options[$name];
117
+ $options[$name] = function ($v, $k) use (&$results, $currentFn) {
118
+ $currentFn($v, $k);
119
+ $results[$k] = $v;
120
+ };
121
+ }
122
+ }
123
+ }
app/api/Ctct/vendor/guzzlehttp/guzzle/src/PrepareBodyMiddleware.php ADDED
@@ -0,0 +1,112 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp;
3
+
4
+ use GuzzleHttp\Promise\PromiseInterface;
5
+ use GuzzleHttp\Psr7;
6
+ use Psr\Http\Message\RequestInterface;
7
+
8
+ /**
9
+ * Prepares requests that contain a body, adding the Content-Length,
10
+ * Content-Type, and Expect headers.
11
+ */
12
+ class PrepareBodyMiddleware
13
+ {
14
+ /** @var callable */
15
+ private $nextHandler;
16
+
17
+ /** @var array */
18
+ private static $skipMethods = ['GET' => true, 'HEAD' => true];
19
+
20
+ /**
21
+ * @param callable $nextHandler Next handler to invoke.
22
+ */
23
+ public function __construct(callable $nextHandler)
24
+ {
25
+ $this->nextHandler = $nextHandler;
26
+ }
27
+
28
+ /**
29
+ * @param RequestInterface $request
30
+ * @param array $options
31
+ *
32
+ * @return PromiseInterface
33
+ */
34
+ public function __invoke(RequestInterface $request, array $options)
35
+ {
36
+ $fn = $this->nextHandler;
37
+
38
+ // Don't do anything if the request has no body.
39
+ if (isset(self::$skipMethods[$request->getMethod()])
40
+ || $request->getBody()->getSize() === 0
41
+ ) {
42
+ return $fn($request, $options);
43
+ }
44
+
45
+ $modify = [];
46
+
47
+ // Add a default content-type if possible.
48
+ if (!$request->hasHeader('Content-Type')) {
49
+ if ($uri = $request->getBody()->getMetadata('uri')) {
50
+ if ($type = Psr7\mimetype_from_filename($uri)) {
51
+ $modify['set_headers']['Content-Type'] = $type;
52
+ }
53
+ }
54
+ }
55
+
56
+ // Add a default content-length or transfer-encoding header.
57
+ if (!isset(self::$skipMethods[$request->getMethod()])
58
+ && !$request->hasHeader('Content-Length')
59
+ && !$request->hasHeader('Transfer-Encoding')
60
+ ) {
61
+ $size = $request->getBody()->getSize();
62
+ if ($size !== null) {
63
+ $modify['set_headers']['Content-Length'] = $size;
64
+ } else {
65
+ $modify['set_headers']['Transfer-Encoding'] = 'chunked';
66
+ }
67
+ }
68
+
69
+ // Add the expect header if needed.
70
+ $this->addExpectHeader($request, $options, $modify);
71
+
72
+ return $fn(Psr7\modify_request($request, $modify), $options);
73
+ }
74
+
75
+ private function addExpectHeader(
76
+ RequestInterface $request,
77
+ array $options,
78
+ array &$modify
79
+ ) {
80
+ // Determine if the Expect header should be used
81
+ if ($request->hasHeader('Expect')) {
82
+ return;
83
+ }
84
+
85
+ $expect = isset($options['expect']) ? $options['expect'] : null;
86
+
87
+ // Return if disabled or if you're not using HTTP/1.1 or HTTP/2.0
88
+ if ($expect === false || $request->getProtocolVersion() < 1.1) {
89
+ return;
90
+ }
91
+
92
+ // The expect header is unconditionally enabled
93
+ if ($expect === true) {
94
+ $modify['set_headers']['Expect'] = '100-Continue';
95
+ return;
96
+ }
97
+
98
+ // By default, send the expect header when the payload is > 1mb
99
+ if ($expect === null) {
100
+ $expect = 1048576;
101
+ }
102
+
103
+ // Always add if the body cannot be rewound, the size cannot be
104
+ // determined, or the size is greater than the cutoff threshold
105
+ $body = $request->getBody();
106
+ $size = $body->getSize();
107
+
108
+ if ($size === null || $size >= (int) $expect || !$body->isSeekable()) {
109
+ $modify['set_headers']['Expect'] = '100-Continue';
110
+ }
111
+ }
112
+ }
app/api/Ctct/vendor/guzzlehttp/guzzle/src/RedirectMiddleware.php ADDED
@@ -0,0 +1,231 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp;
3
+
4
+ use GuzzleHttp\Exception\BadResponseException;
5
+ use GuzzleHttp\Exception\TooManyRedirectsException;
6
+ use GuzzleHttp\Promise\PromiseInterface;
7
+ use GuzzleHttp\Psr7;
8
+ use Psr\Http\Message\RequestInterface;
9
+ use Psr\Http\Message\ResponseInterface;
10
+ use Psr\Http\Message\UriInterface;
11
+
12
+ /**
13
+ * Request redirect middleware.
14
+ *
15
+ * Apply this middleware like other middleware using
16
+ * {@see GuzzleHttp\Middleware::redirect()}.
17
+ */
18
+ class RedirectMiddleware
19
+ {
20
+ const HISTORY_HEADER = 'X-Guzzle-Redirect-History';
21
+
22
+ public static $defaultSettings = [
23
+ 'max' => 5,
24
+ 'protocols' => ['http', 'https'],
25
+ 'strict' => false,
26
+ 'referer' => false,
27
+ 'track_redirects' => false,
28
+ ];
29
+
30
+ /** @var callable */
31
+ private $nextHandler;
32
+
33
+ /**
34
+ * @param callable $nextHandler Next handler to invoke.
35
+ */
36
+ public function __construct(callable $nextHandler)
37
+ {
38
+ $this->nextHandler = $nextHandler;
39
+ }
40
+
41
+ /**
42
+ * @param RequestInterface $request
43
+ * @param array $options
44
+ *
45
+ * @return PromiseInterface
46
+ */
47
+ public function __invoke(RequestInterface $request, array $options)
48
+ {
49
+ $fn = $this->nextHandler;
50
+
51
+ if (empty($options['allow_redirects'])) {
52
+ return $fn($request, $options);
53
+ }
54
+
55
+ if ($options['allow_redirects'] === true) {
56
+ $options['allow_redirects'] = self::$defaultSettings;
57
+ } elseif (!is_array($options['allow_redirects'])) {
58
+ throw new \InvalidArgumentException('allow_redirects must be true, false, or array');
59
+ } else {
60
+ // Merge the default settings with the provided settings
61
+ $options['allow_redirects'] += self::$defaultSettings;
62
+ }
63
+
64
+ if (empty($options['allow_redirects']['max'])) {
65
+ return $fn($request, $options);
66
+ }
67
+
68
+ return $fn($request, $options)
69
+ ->then(function (ResponseInterface $response) use ($request, $options) {
70
+ return $this->checkRedirect($request, $options, $response);
71
+ });
72
+ }
73
+
74
+ /**
75
+ * @param RequestInterface $request
76
+ * @param array $options
77
+ * @param ResponseInterface|PromiseInterface $response
78
+ *
79
+ * @return ResponseInterface|PromiseInterface
80
+ */
81
+ public function checkRedirect(
82
+ RequestInterface $request,
83
+ array $options,
84
+ ResponseInterface $response
85
+ ) {
86
+ if (substr($response->getStatusCode(), 0, 1) != '3'
87
+ || !$response->hasHeader('Location')
88
+ ) {
89
+ return $response;
90
+ }
91
+
92
+ $this->guardMax($request, $options);
93
+ $nextRequest = $this->modifyRequest($request, $options, $response);
94
+
95
+ if (isset($options['allow_redirects']['on_redirect'])) {
96
+ call_user_func(
97
+ $options['allow_redirects']['on_redirect'],
98
+ $request,
99
+ $response,
100
+ $nextRequest->getUri()
101
+ );
102
+ }
103
+
104
+ /** @var PromiseInterface|ResponseInterface $promise */
105
+ $promise = $this($nextRequest, $options);
106
+
107
+ // Add headers to be able to track history of redirects.
108
+ if (!empty($options['allow_redirects']['track_redirects'])) {
109
+ return $this->withTracking(
110
+ $promise,
111
+ (string) $nextRequest->getUri()
112
+ );
113
+ }
114
+
115
+ return $promise;
116
+ }
117
+
118
+ private function withTracking(PromiseInterface $promise, $uri)
119
+ {
120
+ return $promise->then(
121
+ function (ResponseInterface $response) use ($uri) {
122
+ // Note that we are pushing to the front of the list as this
123
+ // would be an earlier response than what is currently present
124
+ // in the history header.
125
+ $header = $response->getHeader(self::HISTORY_HEADER);
126
+ array_unshift($header, $uri);
127
+ return $response->withHeader(self::HISTORY_HEADER, $header);
128
+ }
129
+ );
130
+ }
131
+
132
+ private function guardMax(RequestInterface $request, array &$options)
133
+ {
134
+ $current = isset($options['__redirect_count'])
135
+ ? $options['__redirect_count']
136
+ : 0;
137
+ $options['__redirect_count'] = $current + 1;
138
+ $max = $options['allow_redirects']['max'];
139
+
140
+ if ($options['__redirect_count'] > $max) {
141
+ throw new TooManyRedirectsException(
142
+ "Will not follow more than {$max} redirects",
143
+ $request
144
+ );
145
+ }
146
+ }
147
+
148
+ /**
149
+ * @param RequestInterface $request
150
+ * @param array $options
151
+ * @param ResponseInterface $response
152
+ *
153
+ * @return RequestInterface
154
+ */
155
+ public function modifyRequest(
156
+ RequestInterface $request,
157
+ array $options,
158
+ ResponseInterface $response
159
+ ) {
160
+ // Request modifications to apply.
161
+ $modify = [];
162
+ $protocols = $options['allow_redirects']['protocols'];
163
+
164
+ // Use a GET request if this is an entity enclosing request and we are
165
+ // not forcing RFC compliance, but rather emulating what all browsers
166
+ // would do.
167
+ $statusCode = $response->getStatusCode();
168
+ if ($statusCode == 303 ||
169
+ ($statusCode <= 302 && $request->getBody() && !$options['allow_redirects']['strict'])
170
+ ) {
171
+ $modify['method'] = 'GET';
172
+ $modify['body'] = '';
173
+ }
174
+
175
+ $modify['uri'] = $this->redirectUri($request, $response, $protocols);
176
+ Psr7\rewind_body($request);
177
+
178
+ // Add the Referer header if it is told to do so and only
179
+ // add the header if we are not redirecting from https to http.
180
+ if ($options['allow_redirects']['referer']
181
+ && $modify['uri']->getScheme() === $request->getUri()->getScheme()
182
+ ) {
183
+ $uri = $request->getUri()->withUserInfo('', '');
184
+ $modify['set_headers']['Referer'] = (string) $uri;
185
+ } else {
186
+ $modify['remove_headers'][] = 'Referer';
187
+ }
188
+
189
+ // Remove Authorization header if host is different.
190
+ if ($request->getUri()->getHost() !== $modify['uri']->getHost()) {
191
+ $modify['remove_headers'][] = 'Authorization';
192
+ }
193
+
194
+ return Psr7\modify_request($request, $modify);
195
+ }
196
+
197
+ /**
198
+ * Set the appropriate URL on the request based on the location header
199
+ *
200
+ * @param RequestInterface $request
201
+ * @param ResponseInterface $response
202
+ * @param array $protocols
203
+ *
204
+ * @return UriInterface
205
+ */
206
+ private function redirectUri(
207
+ RequestInterface $request,
208
+ ResponseInterface $response,
209
+ array $protocols
210
+ ) {
211
+ $location = Psr7\Uri::resolve(
212
+ $request->getUri(),
213
+ $response->getHeaderLine('Location')
214
+ );
215
+
216
+ // Ensure that the redirect URI is allowed based on the protocols.
217
+ if (!in_array($location->getScheme(), $protocols)) {
218
+ throw new BadResponseException(
219
+ sprintf(
220
+ 'Redirect URI, %s, does not use one of the allowed redirect protocols: %s',
221
+ $location,
222
+ implode(', ', $protocols)
223
+ ),
224
+ $request,
225
+ $response
226
+ );
227
+ }
228
+
229
+ return $location;
230
+ }
231
+ }
app/api/Ctct/vendor/guzzlehttp/guzzle/src/RequestOptions.php ADDED
@@ -0,0 +1,244 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp;
3
+
4
+ /**
5
+ * This class contains a list of built-in Guzzle request options.
6
+ *
7
+ * More documentation for each option can be found at http://guzzlephp.org/.
8
+ *
9
+ * @link http://docs.guzzlephp.org/en/v6/request-options.html
10
+ */
11
+ final class RequestOptions
12
+ {
13
+ /**
14
+ * allow_redirects: (bool|array) Controls redirect behavior. Pass false
15
+ * to disable redirects, pass true to enable redirects, pass an
16
+ * associative to provide custom redirect settings. Defaults to "false".
17
+ * This option only works if your handler has the RedirectMiddleware. When
18
+ * passing an associative array, you can provide the following key value
19
+ * pairs:
20
+ *
21
+ * - max: (int, default=5) maximum number of allowed redirects.
22
+ * - strict: (bool, default=false) Set to true to use strict redirects
23
+ * meaning redirect POST requests with POST requests vs. doing what most
24
+ * browsers do which is redirect POST requests with GET requests
25
+ * - referer: (bool, default=true) Set to false to disable the Referer
26
+ * header.
27
+ * - protocols: (array, default=['http', 'https']) Allowed redirect
28
+ * protocols.
29
+ * - on_redirect: (callable) PHP callable that is invoked when a redirect
30
+ * is encountered. The callable is invoked with the request, the redirect
31
+ * response that was received, and the effective URI. Any return value
32
+ * from the on_redirect function is ignored.
33
+ */
34
+ const ALLOW_REDIRECTS = 'allow_redirects';
35
+
36
+ /**
37
+ * auth: (array) Pass an array of HTTP authentication parameters to use
38
+ * with the request. The array must contain the username in index [0],
39
+ * the password in index [1], and you can optionally provide a built-in
40
+ * authentication type in index [2]. Pass null to disable authentication
41
+ * for a request.
42
+ */
43
+ const AUTH = 'auth';
44
+
45
+ /**
46
+ * body: (string|null|callable|iterator|object) Body to send in the
47
+ * request.
48
+ */
49
+ const BODY = 'body';
50
+
51
+ /**
52
+ * cert: (string|array) Set to a string to specify the path to a file
53
+ * containing a PEM formatted SSL client side certificate. If a password
54
+ * is required, then set cert to an array containing the path to the PEM
55
+ * file in the first array element followed by the certificate password
56
+ * in the second array element.
57
+ */
58
+ const CERT = 'cert';
59
+
60
+ /**
61
+ * cookies: (bool|GuzzleHttp\Cookie\CookieJarInterface, default=false)
62
+ * Specifies whether or not cookies are used in a request or what cookie
63
+ * jar to use or what cookies to send. This option only works if your
64
+ * handler has the `cookie` middleware. Valid values are `false` and
65
+ * an instance of {@see GuzzleHttp\Cookie\CookieJarInterface}.
66
+ */
67
+ const COOKIES = 'cookies';
68
+
69
+ /**
70
+ * connect_timeout: (float, default=0) Float describing the number of
71
+ * seconds to wait while trying to connect to a server. Use 0 to wait
72
+ * indefinitely (the default behavior).
73
+ */
74
+ const CONNECT_TIMEOUT = 'connect_timeout';
75
+
76
+ /**
77
+ * debug: (bool|resource) Set to true or set to a PHP stream returned by
78
+ * fopen() enable debug output with the HTTP handler used to send a
79
+ * request.
80
+ */
81
+ const DEBUG = 'debug';
82
+
83
+ /**
84
+ * decode_content: (bool, default=true) Specify whether or not
85
+ * Content-Encoding responses (gzip, deflate, etc.) are automatically
86
+ * decoded.
87
+ */
88
+ const DECODE_CONTENT = 'decode_content';
89
+
90
+ /**
91
+ * delay: (int) The amount of time to delay before sending in milliseconds.
92
+ */
93
+ const DELAY = 'delay';
94
+
95
+ /**
96
+ * expect: (bool|integer) Controls the behavior of the
97
+ * "Expect: 100-Continue" header.
98
+ *
99
+ * Set to `true` to enable the "Expect: 100-Continue" header for all
100
+ * requests that sends a body. Set to `false` to disable the
101
+ * "Expect: 100-Continue" header for all requests. Set to a number so that
102
+ * the size of the payload must be greater than the number in order to send
103
+ * the Expect header. Setting to a number will send the Expect header for
104
+ * all requests in which the size of the payload cannot be determined or
105
+ * where the body is not rewindable.
106
+ *
107
+ * By default, Guzzle will add the "Expect: 100-Continue" header when the
108
+ * size of the body of a request is greater than 1 MB and a request is
109
+ * using HTTP/1.1.
110
+ */
111
+ const EXPECT = 'expect';
112
+
113
+ /**
114
+ * form_params: (array) Associative array of form field names to values
115
+ * where each value is a string or array of strings. Sets the Content-Type
116
+ * header to application/x-www-form-urlencoded when no Content-Type header
117
+ * is already present.
118
+ */
119
+ const FORM_PARAMS = 'form_params';
120
+
121
+ /**
122
+ * headers: (array) Associative array of HTTP headers. Each value MUST be
123
+ * a string or array of strings.
124
+ */
125
+ const HEADERS = 'headers';
126
+
127
+ /**
128
+ * http_errors: (bool, default=true) Set to false to disable exceptions
129
+ * when a non- successful HTTP response is received. By default,
130
+ * exceptions will be thrown for 4xx and 5xx responses. This option only
131
+ * works if your handler has the `httpErrors` middleware.
132
+ */
133
+ const HTTP_ERRORS = 'http_errors';
134
+
135
+ /**
136
+ * json: (mixed) Adds JSON data to a request. The provided value is JSON
137
+ * encoded and a Content-Type header of application/json will be added to
138
+ * the request if no Content-Type header is already present.
139
+ */
140
+ const JSON = 'json';
141
+
142
+ /**
143
+ * multipart: (array) Array of associative arrays, each containing a
144
+ * required "name" key mapping to the form field, name, a required
145
+ * "contents" key mapping to a StreamInterface|resource|string, an
146
+ * optional "headers" associative array of custom headers, and an
147
+ * optional "filename" key mapping to a string to send as the filename in
148
+ * the part. If no "filename" key is present, then no "filename" attribute
149
+ * will be added to the part.
150
+ */
151
+ const MULTIPART = 'multipart';
152
+
153
+ /**
154
+ * on_headers: (callable) A callable that is invoked when the HTTP headers
155
+ * of the response have been received but the body has not yet begun to
156
+ * download.
157
+ */
158
+ const ON_HEADERS = 'on_headers';
159
+
160
+ /**
161
+ * on_stats: (callable) allows you to get access to transfer statistics of
162
+ * a request and access the lower level transfer details of the handler
163
+ * associated with your client. ``on_stats`` is a callable that is invoked
164
+ * when a handler has finished sending a request. The callback is invoked
165
+ * with transfer statistics about the request, the response received, or
166
+ * the error encountered. Included in the data is the total amount of time
167
+ * taken to send the request.
168
+ */
169
+ const ON_STATS = 'on_stats';
170
+
171
+ /**
172
+ * progress: (callable) Defines a function to invoke when transfer
173
+ * progress is made. The function accepts the following positional
174
+ * arguments: the total number of bytes expected to be downloaded, the
175
+ * number of bytes downloaded so far, the number of bytes expected to be
176
+ * uploaded, the number of bytes uploaded so far.
177
+ */
178
+ const PROGRESS = 'progress';
179
+
180
+ /**
181
+ * proxy: (string|array) Pass a string to specify an HTTP proxy, or an
182
+ * array to specify different proxies for different protocols (where the
183
+ * key is the protocol and the value is a proxy string).
184
+ */
185
+ const PROXY = 'proxy';
186
+
187
+ /**
188
+ * query: (array|string) Associative array of query string values to add
189
+ * to the request. This option uses PHP's http_build_query() to create
190
+ * the string representation. Pass a string value if you need more
191
+ * control than what this method provides
192
+ */
193
+ const QUERY = 'query';
194
+
195
+ /**
196
+ * sink: (resource|string|StreamInterface) Where the data of the
197
+ * response is written to. Defaults to a PHP temp stream. Providing a
198
+ * string will write data to a file by the given name.
199
+ */
200
+ const SINK = 'sink';
201
+
202
+ /**
203
+ * synchronous: (bool) Set to true to inform HTTP handlers that you intend
204
+ * on waiting on the response. This can be useful for optimizations. Note
205
+ * that a promise is still returned if you are using one of the async
206
+ * client methods.
207
+ */
208
+ const SYNCHRONOUS = 'synchronous';
209
+
210
+ /**
211
+ * ssl_key: (array|string) Specify the path to a file containing a private
212
+ * SSL key in PEM format. If a password is required, then set to an array
213
+ * containing the path to the SSL key in the first array element followed
214
+ * by the password required for the certificate in the second element.
215
+ */
216
+ const SSL_KEY = 'ssl_key';
217
+
218
+ /**
219
+ * stream: Set to true to attempt to stream a response rather than
220
+ * download it all up-front.
221
+ */
222
+ const STREAM = 'stream';
223
+
224
+ /**
225
+ * verify: (bool|string, default=true) Describes the SSL certificate
226
+ * verification behavior of a request. Set to true to enable SSL
227
+ * certificate verification using the system CA bundle when available
228
+ * (the default). Set to false to disable certificate verification (this
229
+ * is insecure!). Set to a string to provide the path to a CA bundle on
230
+ * disk to enable verification using a custom certificate.
231
+ */
232
+ const VERIFY = 'verify';
233
+
234
+ /**
235
+ * timeout: (float, default=0) Float describing the timeout of the
236
+ * request in seconds. Use 0 to wait indefinitely (the default behavior).
237
+ */
238
+ const TIMEOUT = 'timeout';
239
+
240
+ /**
241
+ * version: (float) Specifies the HTTP protocol version to attempt to use.
242
+ */
243
+ const VERSION = 'version';
244
+ }
app/api/Ctct/vendor/guzzlehttp/guzzle/src/RetryMiddleware.php ADDED
@@ -0,0 +1,111 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp;
3
+
4
+ use GuzzleHttp\Promise\PromiseInterface;
5
+ use GuzzleHttp\Promise\RejectedPromise;
6
+ use GuzzleHttp\Psr7;
7
+ use Psr\Http\Message\RequestInterface;
8
+
9
+ /**
10
+ * Middleware that retries requests based on the boolean result of
11
+ * invoking the provided "decider" function.
12
+ */
13
+ class RetryMiddleware
14
+ {
15
+ /** @var callable */
16
+ private $nextHandler;
17
+
18
+ /** @var callable */
19
+ private $decider;
20
+
21
+ /**
22
+ * @param callable $decider Function that accepts the number of retries,
23
+ * a request, [response], and [exception] and
24
+ * returns true if the request is to be
25
+ * retried.
26
+ * @param callable $nextHandler Next handler to invoke.
27
+ * @param callable $delay Function that accepts the number of retries
28
+ * and returns the number of milliseconds to
29
+ * delay.
30
+ */
31
+ public function __construct(
32
+ callable $decider,
33
+ callable $nextHandler,
34
+ callable $delay = null
35
+ ) {
36
+ $this->decider = $decider;
37
+ $this->nextHandler = $nextHandler;
38
+ $this->delay = $delay ?: __CLASS__ . '::exponentialDelay';
39
+ }
40
+
41
+ /**
42
+ * Default exponential backoff delay function.
43
+ *
44
+ * @param $retries
45
+ *
46
+ * @return int
47
+ */
48
+ public static function exponentialDelay($retries)
49
+ {
50
+ return (int) pow(2, $retries - 1);
51
+ }
52
+
53
+ /**
54
+ * @param RequestInterface $request
55
+ * @param array $options
56
+ *
57
+ * @return PromiseInterface
58
+ */
59
+ public function __invoke(RequestInterface $request, array $options)
60
+ {
61
+ if (!isset($options['retries'])) {
62
+ $options['retries'] = 0;
63
+ }
64
+
65
+ $fn = $this->nextHandler;
66
+ return $fn($request, $options)
67
+ ->then(
68
+ $this->onFulfilled($request, $options),
69
+ $this->onRejected($request, $options)
70
+ );
71
+ }
72
+
73
+ private function onFulfilled(RequestInterface $req, array $options)
74
+ {
75
+ return function ($value) use ($req, $options) {
76
+ if (!call_user_func(
77
+ $this->decider,
78
+ $options['retries'],
79
+ $req,
80
+ $value,
81
+ null
82
+ )) {
83
+ return $value;
84
+ }
85
+ return $this->doRetry($req, $options);
86
+ };
87
+ }
88
+
89
+ private function onRejected(RequestInterface $req, array $options)
90
+ {
91
+ return function ($reason) use ($req, $options) {
92
+ if (!call_user_func(
93
+ $this->decider,
94
+ $options['retries'],
95
+ $req,
96
+ null,
97
+ $reason
98
+ )) {
99
+ return new RejectedPromise($reason);
100
+ }
101
+ return $this->doRetry($req, $options);
102
+ };
103
+ }
104
+
105
+ private function doRetry(RequestInterface $request, array $options)
106
+ {
107
+ $options['delay'] = call_user_func($this->delay, ++$options['retries']);
108
+
109
+ return $this($request, $options);
110
+ }
111
+ }
app/api/Ctct/vendor/guzzlehttp/guzzle/src/TransferStats.php ADDED
@@ -0,0 +1,126 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp;
3
+
4
+ use Psr\Http\Message\RequestInterface;
5
+ use Psr\Http\Message\ResponseInterface;
6
+ use Psr\Http\Message\UriInterface;
7
+
8
+ /**
9
+ * Represents data at the point after it was transferred either successfully
10
+ * or after a network error.
11
+ */
12
+ final class TransferStats
13
+ {
14
+ private $request;
15
+ private $response;
16
+ private $transferTime;
17
+ private $handlerStats;
18
+ private $handlerErrorData;
19
+
20
+ /**
21
+ * @param RequestInterface $request Request that was sent.
22
+ * @param ResponseInterface $response Response received (if any)
23
+ * @param null $transferTime Total handler transfer time.
24
+ * @param mixed $handlerErrorData Handler error data.
25
+ * @param array $handlerStats Handler specific stats.
26
+ */
27
+ public function __construct(
28
+ RequestInterface $request,
29
+ ResponseInterface $response = null,
30
+ $transferTime = null,
31
+ $handlerErrorData = null,
32
+ $handlerStats = []
33
+ ) {
34
+ $this->request = $request;
35
+ $this->response = $response;
36
+ $this->transferTime = $transferTime;
37
+ $this->handlerErrorData = $handlerErrorData;
38
+ $this->handlerStats = $handlerStats;
39
+ }
40
+
41
+ /**
42
+ * @return RequestInterface
43
+ */
44
+ public function getRequest()
45
+ {
46
+ return $this->request;
47
+ }
48
+
49
+ /**
50
+ * Returns the response that was received (if any).
51
+ *
52
+ * @return ResponseInterface|null
53
+ */
54
+ public function getResponse()
55
+ {
56
+ return $this->response;
57
+ }
58
+
59
+ /**
60
+ * Returns true if a response was received.
61
+ *
62
+ * @return bool
63
+ */
64
+ public function hasResponse()
65
+ {
66
+ return $this->response !== null;
67
+ }
68
+
69
+ /**
70
+ * Gets handler specific error data.
71
+ *
72
+ * This might be an exception, a integer representing an error code, or
73
+ * anything else. Relying on this value assumes that you know what handler
74
+ * you are using.
75
+ *
76
+ * @return mixed
77
+ */
78
+ public function getHandlerErrorData()
79
+ {
80
+ return $this->handlerErrorData;
81
+ }
82
+
83
+ /**
84
+ * Get the effective URI the request was sent to.
85
+ *
86
+ * @return UriInterface
87
+ */
88
+ public function getEffectiveUri()
89
+ {
90
+ return $this->request->getUri();
91
+ }
92
+
93
+ /**
94
+ * Get the estimated time the request was being transferred by the handler.
95
+ *
96
+ * @return float Time in seconds.
97
+ */
98
+ public function getTransferTime()
99
+ {
100
+ return $this->transferTime;
101
+ }
102
+
103
+ /**
104
+ * Gets an array of all of the handler specific transfer data.
105
+ *
106
+ * @return array
107
+ */
108
+ public function getHandlerStats()
109
+ {
110
+ return $this->handlerStats;
111
+ }
112
+
113
+ /**
114
+ * Get a specific handler statistic from the handler by name.
115
+ *
116
+ * @param string $stat Handler specific transfer stat to retrieve.
117
+ *
118
+ * @return mixed|null
119
+ */
120
+ public function getHandlerStat($stat)
121
+ {
122
+ return isset($this->handlerStats[$stat])
123
+ ? $this->handlerStats[$stat]
124
+ : null;
125
+ }
126
+ }
app/api/Ctct/vendor/guzzlehttp/guzzle/src/UriTemplate.php ADDED
@@ -0,0 +1,241 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp;
3
+
4
+ /**
5
+ * Expands URI templates. Userland implementation of PECL uri_template.
6
+ *
7
+ * @link http://tools.ietf.org/html/rfc6570
8
+ */
9
+ class UriTemplate
10
+ {
11
+ /** @var string URI template */
12
+ private $template;
13
+
14
+ /** @var array Variables to use in the template expansion */
15
+ private $variables;
16
+
17
+ /** @var array Hash for quick operator lookups */
18
+ private static $operatorHash = array(
19
+ '' => array('prefix' => '', 'joiner' => ',', 'query' => false),
20
+ '+' => array('prefix' => '', 'joiner' => ',', 'query' => false),
21
+ '#' => array('prefix' => '#', 'joiner' => ',', 'query' => false),
22
+ '.' => array('prefix' => '.', 'joiner' => '.', 'query' => false),
23
+ '/' => array('prefix' => '/', 'joiner' => '/', 'query' => false),
24
+ ';' => array('prefix' => ';', 'joiner' => ';', 'query' => true),
25
+ '?' => array('prefix' => '?', 'joiner' => '&', 'query' => true),
26
+ '&' => array('prefix' => '&', 'joiner' => '&', 'query' => true)
27
+ );
28
+
29
+ /** @var array Delimiters */
30
+ private static $delims = array(':', '/', '?', '#', '[', ']', '@', '!', '$',
31
+ '&', '\'', '(', ')', '*', '+', ',', ';', '=');
32
+
33
+ /** @var array Percent encoded delimiters */
34
+ private static $delimsPct = array('%3A', '%2F', '%3F', '%23', '%5B', '%5D',
35
+ '%40', '%21', '%24', '%26', '%27', '%28', '%29', '%2A', '%2B', '%2C',
36
+ '%3B', '%3D');
37
+
38
+ public function expand($template, array $variables)
39
+ {
40
+ if (false === strpos($template, '{')) {
41
+ return $template;
42
+ }
43
+
44
+ $this->template = $template;
45
+ $this->variables = $variables;
46
+
47
+ return preg_replace_callback(
48
+ '/\{([^\}]+)\}/',
49
+ [$this, 'expandMatch'],
50
+ $this->template
51
+ );
52
+ }
53
+
54
+ /**
55
+ * Parse an expression into parts
56
+ *
57
+ * @param string $expression Expression to parse
58
+ *
59
+ * @return array Returns an associative array of parts
60
+ */
61
+ private function parseExpression($expression)
62
+ {
63
+ $result = array();
64
+
65
+ if (isset(self::$operatorHash[$expression[0]])) {
66
+ $result['operator'] = $expression[0];
67
+ $expression = substr($expression, 1);
68
+ } else {
69
+ $result['operator'] = '';
70
+ }
71
+
72
+ foreach (explode(',', $expression) as $value) {
73
+ $value = trim($value);
74
+ $varspec = array();
75
+ if ($colonPos = strpos($value, ':')) {
76
+ $varspec['value'] = substr($value, 0, $colonPos);
77
+ $varspec['modifier'] = ':';
78
+ $varspec['position'] = (int) substr($value, $colonPos + 1);
79
+ } elseif (substr($value, -1) == '*') {
80
+ $varspec['modifier'] = '*';
81
+ $varspec['value'] = substr($value, 0, -1);
82
+ } else {
83
+ $varspec['value'] = (string) $value;
84
+ $varspec['modifier'] = '';
85
+ }
86
+ $result['values'][] = $varspec;
87
+ }
88
+
89
+ return $result;
90
+ }
91
+
92
+ /**
93
+ * Process an expansion
94
+ *
95
+ * @param array $matches Matches met in the preg_replace_callback
96
+ *
97
+ * @return string Returns the replacement string
98
+ */
99
+ private function expandMatch(array $matches)
100
+ {
101
+ static $rfc1738to3986 = array('+' => '%20', '%7e' => '~');
102
+
103
+ $replacements = array();
104
+ $parsed = self::parseExpression($matches[1]);
105
+ $prefix = self::$operatorHash[$parsed['operator']]['prefix'];
106
+ $joiner = self::$operatorHash[$parsed['operator']]['joiner'];
107
+ $useQuery = self::$operatorHash[$parsed['operator']]['query'];
108
+
109
+ foreach ($parsed['values'] as $value) {
110
+
111
+ if (!isset($this->variables[$value['value']])) {
112
+ continue;
113
+ }
114
+
115
+ $variable = $this->variables[$value['value']];
116
+ $actuallyUseQuery = $useQuery;
117
+ $expanded = '';
118
+
119
+ if (is_array($variable)) {
120
+
121
+ $isAssoc = $this->isAssoc($variable);
122
+ $kvp = array();
123
+ foreach ($variable as $key => $var) {
124
+
125
+ if ($isAssoc) {
126
+ $key = rawurlencode($key);
127
+ $isNestedArray = is_array($var);
128
+ } else {
129
+ $isNestedArray = false;
130
+ }
131
+
132
+ if (!$isNestedArray) {
133
+ $var = rawurlencode($var);
134
+ if ($parsed['operator'] == '+' ||
135
+ $parsed['operator'] == '#'
136
+ ) {
137
+ $var = $this->decodeReserved($var);
138
+ }
139
+ }
140
+
141
+ if ($value['modifier'] == '*') {
142
+ if ($isAssoc) {
143
+ if ($isNestedArray) {
144
+ // Nested arrays must allow for deeply nested
145
+ // structures.
146
+ $var = strtr(
147
+ http_build_query([$key => $var]),
148
+ $rfc1738to3986
149
+ );
150
+ } else {
151
+ $var = $key . '=' . $var;
152
+ }
153
+ } elseif ($key > 0 && $actuallyUseQuery) {
154
+ $var = $value['value'] . '=' . $var;
155
+ }
156
+ }
157
+
158
+ $kvp[$key] = $var;
159
+ }
160
+
161
+ if (empty($variable)) {
162
+ $actuallyUseQuery = false;
163
+ } elseif ($value['modifier'] == '*') {
164
+ $expanded = implode($joiner, $kvp);
165
+ if ($isAssoc) {
166
+ // Don't prepend the value name when using the explode
167
+ // modifier with an associative array.
168
+ $actuallyUseQuery = false;
169
+ }
170
+ } else {
171
+ if ($isAssoc) {
172
+ // When an associative array is encountered and the
173
+ // explode modifier is not set, then the result must be
174
+ // a comma separated list of keys followed by their
175
+ // respective values.
176
+ foreach ($kvp as $k => &$v) {
177
+ $v = $k . ',' . $v;
178
+ }
179
+ }
180
+ $expanded = implode(',', $kvp);
181
+ }
182
+
183
+ } else {
184
+ if ($value['modifier'] == ':') {
185
+ $variable = substr($variable, 0, $value['position']);
186
+ }
187
+ $expanded = rawurlencode($variable);
188
+ if ($parsed['operator'] == '+' || $parsed['operator'] == '#') {
189
+ $expanded = $this->decodeReserved($expanded);
190
+ }
191
+ }
192
+
193
+ if ($actuallyUseQuery) {
194
+ if (!$expanded && $joiner != '&') {
195
+ $expanded = $value['value'];
196
+ } else {
197
+ $expanded = $value['value'] . '=' . $expanded;
198
+ }
199
+ }
200
+
201
+ $replacements[] = $expanded;
202
+ }
203
+
204
+ $ret = implode($joiner, $replacements);
205
+ if ($ret && $prefix) {
206
+ return $prefix . $ret;
207
+ }
208
+
209
+ return $ret;
210
+ }
211
+
212
+ /**
213
+ * Determines if an array is associative.
214
+ *
215
+ * This makes the assumption that input arrays are sequences or hashes.
216
+ * This assumption is a tradeoff for accuracy in favor of speed, but it
217
+ * should work in almost every case where input is supplied for a URI
218
+ * template.
219
+ *
220
+ * @param array $array Array to check
221
+ *
222
+ * @return bool
223
+ */
224
+ private function isAssoc(array $array)
225
+ {
226
+ return $array && array_keys($array)[0] !== 0;
227
+ }
228
+
229
+ /**
230
+ * Removes percent encoding on reserved characters (used with + and #
231
+ * modifiers).
232
+ *
233
+ * @param string $string String to fix
234
+ *
235
+ * @return string
236
+ */
237
+ private function decodeReserved($string)
238
+ {
239
+ return str_replace(self::$delimsPct, self::$delims, $string);
240
+ }
241
+ }
app/api/Ctct/vendor/guzzlehttp/guzzle/src/functions.php ADDED
@@ -0,0 +1,284 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp;
3
+
4
+ use GuzzleHttp\Handler\CurlHandler;
5
+ use GuzzleHttp\Handler\CurlMultiHandler;
6
+ use GuzzleHttp\Handler\Proxy;
7
+ use GuzzleHttp\Handler\StreamHandler;
8
+ use Psr\Http\Message\StreamInterface;
9
+
10
+ /**
11
+ * Expands a URI template
12
+ *
13
+ * @param string $template URI template
14
+ * @param array $variables Template variables
15
+ *
16
+ * @return string
17
+ */
18
+ function uri_template($template, array $variables)
19
+ {
20
+ if (extension_loaded('uri_template')) {
21
+ // @codeCoverageIgnoreStart
22
+ return \uri_template($template, $variables);
23
+ // @codeCoverageIgnoreEnd
24
+ }
25
+
26
+ static $uriTemplate;
27
+ if (!$uriTemplate) {
28
+ $uriTemplate = new UriTemplate();
29
+ }
30
+
31
+ return $uriTemplate->expand($template, $variables);
32
+ }
33
+
34
+ /**
35
+ * Debug function used to describe the provided value type and class.
36
+ *
37
+ * @param mixed $input
38
+ *
39
+ * @return string Returns a string containing the type of the variable and
40
+ * if a class is provided, the class name.
41
+ */
42
+ function describe_type($input)
43
+ {
44
+ switch (gettype($input)) {
45
+ case 'object':
46
+ return 'object(' . get_class($input) . ')';
47
+ case 'array':
48
+ return 'array(' . count($input) . ')';
49
+ default:
50
+ ob_start();
51
+ var_dump($input);
52
+ // normalize float vs double
53
+ return str_replace('double(', 'float(', rtrim(ob_get_clean()));
54
+ }
55
+ }
56
+
57
+ /**
58
+ * Parses an array of header lines into an associative array of headers.
59
+ *
60
+ * @param array $lines Header lines array of strings in the following
61
+ * format: "Name: Value"
62
+ * @return array
63
+ */
64
+ function headers_from_lines($lines)
65
+ {
66
+ $headers = [];
67
+
68
+ foreach ($lines as $line) {
69
+ $parts = explode(':', $line, 2);
70
+ $headers[trim($parts[0])][] = isset($parts[1])
71
+ ? trim($parts[1])
72
+ : null;
73
+ }
74
+
75
+ return $headers;
76
+ }
77
+
78
+ /**
79
+ * Returns a debug stream based on the provided variable.
80
+ *
81
+ * @param mixed $value Optional value
82
+ *
83
+ * @return resource
84
+ */
85
+ function debug_resource($value = null)
86
+ {
87
+ if (is_resource($value)) {
88
+ return $value;
89
+ } elseif (defined('STDOUT')) {
90
+ return STDOUT;
91
+ }
92
+
93
+ return fopen('php://output', 'w');
94
+ }
95
+
96
+ /**
97
+ * Chooses and creates a default handler to use based on the environment.
98
+ *
99
+ * The returned handler is not wrapped by any default middlewares.
100
+ *
101
+ * @throws \RuntimeException if no viable Handler is available.
102
+ * @return callable Returns the best handler for the given system.
103
+ */
104
+ function choose_handler()
105
+ {
106
+ $handler = null;
107
+ if (function_exists('curl_multi_exec') && function_exists('curl_exec')) {
108
+ $handler = Proxy::wrapSync(new CurlMultiHandler(), new CurlHandler());
109
+ } elseif (function_exists('curl_exec')) {
110
+ $handler = new CurlHandler();
111
+ } elseif (function_exists('curl_multi_exec')) {
112
+ $handler = new CurlMultiHandler();
113
+ }
114
+
115
+ if (ini_get('allow_url_fopen')) {
116
+ $handler = $handler
117
+ ? Proxy::wrapStreaming($handler, new StreamHandler())
118
+ : new StreamHandler();
119
+ } elseif (!$handler) {
120
+ throw new \RuntimeException('GuzzleHttp requires cURL, the '
121
+ . 'allow_url_fopen ini setting, or a custom HTTP handler.');
122
+ }
123
+
124
+ return $handler;
125
+ }
126
+
127
+ /**
128
+ * Get the default User-Agent string to use with Guzzle
129
+ *
130
+ * @return string
131
+ */
132
+ function default_user_agent()
133
+ {
134
+ static $defaultAgent = '';
135
+
136
+ if (!$defaultAgent) {
137
+ $defaultAgent = 'GuzzleHttp/' . Client::VERSION;
138
+ if (extension_loaded('curl') && function_exists('curl_version')) {
139
+ $defaultAgent .= ' curl/' . \curl_version()['version'];
140
+ }
141
+ $defaultAgent .= ' PHP/' . PHP_VERSION;
142
+ }
143
+
144
+ return $defaultAgent;
145
+ }
146
+
147
+ /**
148
+ * Returns the default cacert bundle for the current system.
149
+ *
150
+ * First, the openssl.cafile and curl.cainfo php.ini settings are checked.
151
+ * If those settings are not configured, then the common locations for
152
+ * bundles found on Red Hat, CentOS, Fedora, Ubuntu, Debian, FreeBSD, OS X
153
+ * and Windows are checked. If any of these file locations are found on
154
+ * disk, they will be utilized.
155
+ *
156
+ * Note: the result of this function is cached for subsequent calls.
157
+ *
158
+ * @return string
159
+ * @throws \RuntimeException if no bundle can be found.
160
+ */
161
+ function default_ca_bundle()
162
+ {
163
+ static $cached = null;
164
+ static $cafiles = [
165
+ // Red Hat, CentOS, Fedora (provided by the ca-certificates package)
166
+ '/etc/pki/tls/certs/ca-bundle.crt',
167
+ // Ubuntu, Debian (provided by the ca-certificates package)
168
+ '/etc/ssl/certs/ca-certificates.crt',
169
+ // FreeBSD (provided by the ca_root_nss package)
170
+ '/usr/local/share/certs/ca-root-nss.crt',
171
+ // OS X provided by homebrew (using the default path)
172
+ '/usr/local/etc/openssl/cert.pem',
173
+ // Google app engine
174
+ '/etc/ca-certificates.crt',
175
+ // Windows?
176
+ 'C:\\windows\\system32\\curl-ca-bundle.crt',
177
+ 'C:\\windows\\curl-ca-bundle.crt',
178
+ ];
179
+
180
+ if ($cached) {
181
+ return $cached;
182
+ }
183
+
184
+ if ($ca = ini_get('openssl.cafile')) {
185
+ return $cached = $ca;
186
+ }
187
+
188
+ if ($ca = ini_get('curl.cainfo')) {
189
+ return $cached = $ca;
190
+ }
191
+
192
+ foreach ($cafiles as $filename) {
193
+ if (file_exists($filename)) {
194
+ return $cached = $filename;
195
+ }
196
+ }
197
+
198
+ throw new \RuntimeException(<<< EOT
199
+ No system CA bundle could be found in any of the the common system locations.
200
+ PHP versions earlier than 5.6 are not properly configured to use the system's
201
+ CA bundle by default. In order to verify peer certificates, you will need to
202
+ supply the path on disk to a certificate bundle to the 'verify' request
203
+ option: http://docs.guzzlephp.org/en/latest/clients.html#verify. If you do not
204
+ need a specific certificate bundle, then Mozilla provides a commonly used CA
205
+ bundle which can be downloaded here (provided by the maintainer of cURL):
206
+ https://raw.githubusercontent.com/bagder/ca-bundle/master/ca-bundle.crt. Once
207
+ you have a CA bundle available on disk, you can set the 'openssl.cafile' PHP
208
+ ini setting to point to the path to the file, allowing you to omit the 'verify'
209
+ request option. See http://curl.haxx.se/docs/sslcerts.html for more
210
+ information.
211
+ EOT
212
+ );
213
+ }
214
+
215
+ /**
216
+ * Creates an associative array of lowercase header names to the actual
217
+ * header casing.
218
+ *
219
+ * @param array $headers
220
+ *
221
+ * @return array
222
+ */
223
+ function normalize_header_keys(array $headers)
224
+ {
225
+ $result = [];
226
+ foreach (array_keys($headers) as $key) {
227
+ $result[strtolower($key)] = $key;
228
+ }
229
+
230
+ return $result;
231
+ }
232
+
233
+ /**
234
+ * Returns true if the provided host matches any of the no proxy areas.
235
+ *
236
+ * This method will strip a port from the host if it is present. Each pattern
237
+ * can be matched with an exact match (e.g., "foo.com" == "foo.com") or a
238
+ * partial match: (e.g., "foo.com" == "baz.foo.com" and ".foo.com" ==
239
+ * "baz.foo.com", but ".foo.com" != "foo.com").
240
+ *
241
+ * Areas are matched in the following cases:
242
+ * 1. "*" (without quotes) always matches any hosts.
243
+ * 2. An exact match.
244
+ * 3. The area starts with "." and the area is the last part of the host. e.g.
245
+ * '.mit.edu' will match any host that ends with '.mit.edu'.
246
+ *
247
+ * @param string $host Host to check against the patterns.
248
+ * @param array $noProxyArray An array of host patterns.
249
+ *
250
+ * @return bool
251
+ */
252
+ function is_host_in_noproxy($host, array $noProxyArray)
253
+ {
254
+ if (strlen($host) === 0) {
255
+ throw new \InvalidArgumentException('Empty host provided');
256
+ }
257
+
258
+ // Strip port if present.
259
+ if (strpos($host, ':')) {
260
+ $host = explode($host, ':', 2)[0];
261
+ }
262
+
263
+ foreach ($noProxyArray as $area) {
264
+ // Always match on wildcards.
265
+ if ($area === '*') {
266
+ return true;
267
+ } elseif (empty($area)) {
268
+ // Don't match on empty values.
269
+ continue;
270
+ } elseif ($area === $host) {
271
+ // Exact matches.
272
+ return true;
273
+ } else {
274
+ // Special match if the area when prefixed with ".". Remove any
275
+ // existing leading "." and add a new leading ".".
276
+ $area = '.' . ltrim($area, '.');
277
+ if (substr($host, -(strlen($area))) === $area) {
278
+ return true;
279
+ }
280
+ }
281
+ }
282
+
283
+ return false;
284
+ }
app/api/Ctct/vendor/guzzlehttp/guzzle/src/functions_include.php ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // Don't redefine the functions if included multiple times.
4
+ if (!function_exists('GuzzleHttp\uri_template')) {
5
+ require __DIR__ . '/functions.php';
6
+ }
app/api/Ctct/vendor/guzzlehttp/promises/.gitignore ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ phpunit.xml
2
+ composer.phar
3
+ composer.lock
4
+ composer-test.lock
5
+ vendor/
6
+ build/artifacts/
7
+ artifacts/
8
+ docs/_build
9
+ docs/*.pyc
10
+ .idea
11
+ .DS_STORE
app/api/Ctct/vendor/guzzlehttp/promises/.travis.yml ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ language: php
2
+
3
+ php:
4
+ - 5.5
5
+ - 5.6
6
+ - 7.0
7
+ - hhvm
8
+
9
+ sudo: false
10
+
11
+ install:
12
+ - travis_retry composer install --no-interaction --prefer-source
13
+
14
+ script: make test
15
+
16
+ matrix:
17
+ allow_failures:
18
+ - php: hhvm
19
+ fast_finish: true
app/api/Ctct/vendor/guzzlehttp/promises/CHANGELOG.md ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # CHANGELOG
2
+
3
+ ## 1.0.3 - 2015-10-15
4
+
5
+ * Update EachPromise to immediately resolve when the underlying promise iterator
6
+ is empty. Previously, such a promise would throw an exception when its `wait`
7
+ function was called.
8
+
9
+ ## 1.0.2 - 2015-05-15
10
+
11
+ * Conditionally require functions.php.
12
+
13
+ ## 1.0.1 - 2015-06-24
14
+
15
+ * Updating EachPromise to call next on the underlying promise iterator as late
16
+ as possible to ensure that generators that generate new requests based on
17
+ callbacks are not iterated until after callbacks are invoked.
18
+
19
+ ## 1.0.0 - 2015-05-12
20
+
21
+ * Initial release
app/api/Ctct/vendor/guzzlehttp/promises/LICENSE ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Copyright (c) 2015 Michael Dowling, https://github.com/mtdowling <mtdowling@gmail.com>
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.
app/api/Ctct/vendor/guzzlehttp/promises/Makefile ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ all: clean test
2
+
3
+ test:
4
+ vendor/bin/phpunit
5
+
6
+ coverage:
7
+ vendor/bin/phpunit --coverage-html=artifacts/coverage
8
+
9
+ view-coverage:
10
+ open artifacts/coverage/index.html
11
+
12
+ clean:
13
+ rm -rf artifacts/*
app/api/Ctct/vendor/guzzlehttp/promises/README.md ADDED
@@ -0,0 +1,501 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Guzzle Promises
2
+
3
+ [Promises/A+](https://promisesaplus.com/) implementation that handles promise
4
+ chaining and resolution iteratively, allowing for "infinite" promise chaining
5
+ while keeping the stack size constant. Read [this blog post](https://blog.domenic.me/youre-missing-the-point-of-promises/)
6
+ for a general introduction to promises.
7
+
8
+ - [Features](#features)
9
+ - [Quick start](#quick-start)
10
+ - [Synchronous wait](#synchronous-wait)
11
+ - [Cancellation](#cancellation)
12
+ - [API](#api)
13
+ - [Promise](#promise)
14
+ - [FulfilledPromise](#fulfilledpromise)
15
+ - [RejectedPromise](#rejectedpromise)
16
+ - [Promise interop](#promise-interop)
17
+ - [Implementation notes](#implementation-notes)
18
+
19
+
20
+ # Features
21
+
22
+ - [Promises/A+](https://promisesaplus.com/) implementation.
23
+ - Promise resolution and chaining is handled iteratively, allowing for
24
+ "infinite" promise chaining.
25
+ - Promises have a synchronous `wait` method.
26
+ - Promises can be cancelled.
27
+ - Works with any object that has a `then` function.
28
+ - C# style async/await coroutine promises using
29
+ `GuzzleHttp\Promise\coroutine()`.
30
+
31
+
32
+ # Quick start
33
+
34
+ A *promise* represents the eventual result of an asynchronous operation. The
35
+ primary way of interacting with a promise is through its `then` method, which
36
+ registers callbacks to receive either a promise's eventual value or the reason
37
+ why the promise cannot be fulfilled.
38
+
39
+
40
+ ## Callbacks
41
+
42
+ Callbacks are registered with the `then` method by providing an optional
43
+ `$onFulfilled` followed by an optional `$onRejected` function.
44
+
45
+
46
+ ```php
47
+ use GuzzleHttp\Promise\Promise;
48
+
49
+ $promise = new Promise();
50
+ $promise->then(
51
+ // $onFulfilled
52
+ function ($value) {
53
+ echo 'The promise was fulfilled.';
54
+ },
55
+ // $onRejected
56
+ function ($reason) {
57
+ echo 'The promise was rejected.';
58
+ }
59
+ );
60
+ ```
61
+
62
+ *Resolving* a promise means that you either fulfill a promise with a *value* or
63
+ reject a promise with a *reason*. Resolving a promises triggers callbacks
64
+ registered with the promises's `then` method. These callbacks are triggered
65
+ only once and in the order in which they were added.
66
+
67
+
68
+ ## Resolving a promise
69
+
70
+ Promises are fulfilled using the `resolve($value)` method. Resolving a promise
71
+ with any value other than a `GuzzleHttp\Promise\RejectedPromise` will trigger
72
+ all of the onFulfilled callbacks (resolving a promise with a rejected promise
73
+ will reject the promise and trigger the `$onRejected` callbacks).
74
+
75
+ ```php
76
+ use GuzzleHttp\Promise\Promise;
77
+
78
+ $promise = new Promise();
79
+ $promise
80
+ ->then(function ($value) {
81
+ // Return a value and don't break the chain
82
+ return "Hello, " . $value;
83
+ })
84
+ // This then is executed after the first then and receives the value
85
+ // returned from the first then.
86
+ ->then(function ($value) {
87
+ echo $value;
88
+ });
89
+
90
+ // Resolving the promise triggers the $onFulfilled callbacks and outputs
91
+ // "Hello, reader".
92
+ $promise->resolve('reader.');
93
+ ```
94
+
95
+
96
+ ## Promise forwarding
97
+
98
+ Promises can be chained one after the other. Each then in the chain is a new
99
+ promise. The return value of of a promise is what's forwarded to the next
100
+ promise in the chain. Returning a promise in a `then` callback will cause the
101
+ subsequent promises in the chain to only be fulfilled when the returned promise
102
+ has been fulfilled. The next promise in the chain will be invoked with the
103
+ resolved value of the promise.
104
+
105
+ ```php
106
+ use GuzzleHttp\Promise\Promise;
107
+
108
+ $promise = new Promise();
109
+ $nextPromise = new Promise();
110
+
111
+ $promise
112
+ ->then(function ($value) use ($nextPromise) {
113
+ echo $value;
114
+ return $nextPromise;
115
+ })
116
+ ->then(function ($value) {
117
+ echo $value;
118
+ });
119
+
120
+ // Triggers the first callback and outputs "A"
121
+ $promise->resolve('A');
122
+ // Triggers the second callback and outputs "B"
123
+ $nextPromise->resolve('B');
124
+ ```
125
+
126
+ ## Promise rejection
127
+
128
+ When a promise is rejected, the `$onRejected` callbacks are invoked with the
129
+ rejection reason.
130
+
131
+ ```php
132
+ use GuzzleHttp\Promise\Promise;
133
+
134
+ $promise = new Promise();
135
+ $promise->then(null, function ($reason) {
136
+ echo $reason;
137
+ });
138
+
139
+ $promise->reject('Error!');
140
+ // Outputs "Error!"
141
+ ```
142
+
143
+ ## Rejection forwarding
144
+
145
+ If an exception is thrown in an `$onRejected` callback, subsequent
146
+ `$onRejected` callbacks are invoked with the thrown exception as the reason.
147
+
148
+ ```php
149
+ use GuzzleHttp\Promise\Promise;
150
+
151
+ $promise = new Promise();
152
+ $promise->then(null, function ($reason) {
153
+ throw new \Exception($reason);
154
+ })->then(null, function ($reason) {
155
+ assert($reason->getMessage() === 'Error!');
156
+ });
157
+
158
+ $promise->reject('Error!');
159
+ ```
160
+
161
+ You can also forward a rejection down the promise chain by returning a
162
+ `GuzzleHttp\Promise\RejectedPromise` in either an `$onFulfilled` or
163
+ `$onRejected` callback.
164
+
165
+ ```php
166
+ use GuzzleHttp\Promise\Promise;
167
+ use GuzzleHttp\Promise\RejectedPromise;
168
+
169
+ $promise = new Promise();
170
+ $promise->then(null, function ($reason) {
171
+ return new RejectedPromise($reason);
172
+ })->then(null, function ($reason) {
173
+ assert($reason === 'Error!');
174
+ });
175
+
176
+ $promise->reject('Error!');
177
+ ```
178
+
179
+ If an exception is not thrown in a `$onRejected` callback and the callback
180
+ does not return a rejected promise, downstream `$onFulfilled` callbacks are
181
+ invoked using the value returned from the `$onRejected` callback.
182
+
183
+ ```php
184
+ use GuzzleHttp\Promise\Promise;
185
+ use GuzzleHttp\Promise\RejectedPromise;
186
+
187
+ $promise = new Promise();
188
+ $promise
189
+ ->then(null, function ($reason) {
190
+ return "It's ok";
191
+ })
192
+ ->then(function ($value) {
193
+ assert($value === "It's ok");
194
+ });
195
+
196
+ $promise->reject('Error!');
197
+ ```
198
+
199
+ # Synchronous wait
200
+
201
+ You can synchronously force promises to complete using a promise's `wait`
202
+ method. When creating a promise, you can provide a wait function that is used
203
+ to synchronously force a promise to complete. When a wait function is invoked
204
+ it is expected to deliver a value to the promise or reject the promise. If the
205
+ wait function does not deliver a value, then an exception is thrown. The wait
206
+ function provided to a promise constructor is invoked when the `wait` function
207
+ of the promise is called.
208
+
209
+ ```php
210
+ $promise = new Promise(function () use (&$promise) {
211
+ $promise->deliver('foo');
212
+ });
213
+
214
+ // Calling wait will return the value of the promise.
215
+ echo $promise->wait(); // outputs "foo"
216
+ ```
217
+
218
+ If an exception is encountered while invoking the wait function of a promise,
219
+ the promise is rejected with the exception and the exception is thrown.
220
+
221
+ ```php
222
+ $promise = new Promise(function () use (&$promise) {
223
+ throw new \Exception('foo');
224
+ });
225
+
226
+ $promise->wait(); // throws the exception.
227
+ ```
228
+
229
+ Calling `wait` on a promise that has been fulfilled will not trigger the wait
230
+ function. It will simply return the previously delivered value.
231
+
232
+ ```php
233
+ $promise = new Promise(function () { die('this is not called!'); });
234
+ $promise->deliver('foo');
235
+ echo $promise->wait(); // outputs "foo"
236
+ ```
237
+
238
+ Calling `wait` on a promise that has been rejected will throw an exception. If
239
+ the rejection reason is an instance of `\Exception` the reason is thrown.
240
+ Otherwise, a `GuzzleHttp\Promise\RejectionException` is thrown and the reason
241
+ can be obtained by calling the `getReason` method of the exception.
242
+
243
+ ```php
244
+ $promise = new Promise();
245
+ $promise->reject('foo');
246
+ $promise->wait();
247
+ ```
248
+
249
+ > PHP Fatal error: Uncaught exception 'GuzzleHttp\Promise\RejectionException' with message 'The promise was rejected with value: foo'
250
+
251
+
252
+ ## Unwrapping a promise
253
+
254
+ When synchronously waiting on a promise, you are joining the state of the
255
+ promise into the current state of execution (i.e., return the value of the
256
+ promise if it was fulfilled or throw an exception if it was rejected). This is
257
+ called "unwrapping" the promise. Waiting on a promise will by default unwrap
258
+ the promise state.
259
+
260
+ You can force a promise to resolve and *not* unwrap the state of the promise
261
+ by passing `false` to the first argument of the `wait` function:
262
+
263
+ ```php
264
+ $promise = new Promise();
265
+ $promise->reject('foo');
266
+ // This will not throw an exception. It simply ensures the promise has
267
+ // been resolved.
268
+ $promise->wait(false);
269
+ ```
270
+
271
+ When unwrapping a promise, the delivered value of the promise will be waited
272
+ upon until the unwrapped value is not a promise. This means that if you resolve
273
+ promise A with a promise B and unwrap promise A, the value returned by the
274
+ wait function will be the value delivered to promise B.
275
+
276
+ **Note**: when you do not unwrap the promise, no value is returned.
277
+
278
+
279
+ # Cancellation
280
+
281
+ You can cancel a promise that has not yet been fulfilled using the `cancel()`
282
+ method of a promise. When creating a promise you can provide an optional
283
+ cancel function that when invoked cancels the action of computing a resolution
284
+ of the promise.
285
+
286
+
287
+ # API
288
+
289
+
290
+ ## Promise
291
+
292
+ When creating a promise object, you can provide an optional `$waitFn` and
293
+ `$cancelFn`. `$waitFn` is a function that is invoked with no arguments and is
294
+ expected to resolve the promise. `$cancelFn` is a function with no arguments
295
+ that is expected to cancel the computation of a promise. It is invoked when the
296
+ `cancel()` method of a promise is called.
297
+
298
+ ```php
299
+ use GuzzleHttp\Promise\Promise;
300
+
301
+ $promise = new Promise(
302
+ function () use (&$promise) {
303
+ $promise->resolve('waited');
304
+ },
305
+ function () {
306
+ // do something that will cancel the promise computation (e.g., close
307
+ // a socket, cancel a database query, etc...)
308
+ }
309
+ );
310
+
311
+ assert('waited' === $promise->wait());
312
+ ```
313
+
314
+ A promise has the following methods:
315
+
316
+ - `then(callable $onFulfilled, callable $onRejected) : PromiseInterface`
317
+
318
+ Creates a new promise that is fulfilled or rejected when the promise is
319
+ resolved.
320
+
321
+ - `wait($unwrap = true) : mixed`
322
+
323
+ Synchronously waits on the promise to complete.
324
+
325
+ `$unwrap` controls whether or not the value of the promise is returned for a
326
+ fulfilled promise or if an exception is thrown if the promise is rejected.
327
+ This is set to `true` by default.
328
+
329
+ - `cancel()`
330
+
331
+ Attempts to cancel the promise if possible. The promise being cancelled and
332
+ the parent most ancestor that has not yet been resolved will also be
333
+ cancelled. Any promises waiting on the cancelled promise to resolve will also
334
+ be cancelled.
335
+
336
+ - `getState() : string`
337
+
338
+ Returns the state of the promise. One of `pending`, `fulfilled`, or
339
+ `rejected`.
340
+
341
+ - `resolve($value)`
342
+
343
+ Fulfills the promise with the given `$value`.
344
+
345
+ - `reject($reason)`
346
+
347
+ Rejects the promise with the given `$reason`.
348
+
349
+
350
+ ## FulfilledPromise
351
+
352
+ A fulfilled promise can be created to represent a promise that has been
353
+ fulfilled.
354
+
355
+ ```php
356
+ use GuzzleHttp\Promise\FulfilledPromise;
357
+
358
+ $promise = new FulfilledPromise('value');
359
+
360
+ // Fulfilled callbacks are immediately invoked.
361
+ $promise->then(function ($value) {
362
+ echo $value;
363
+ });
364
+ ```
365
+
366
+
367
+ ## RejectedPromise
368
+
369
+ A rejected promise can be created to represent a promise that has been
370
+ rejected.
371
+
372
+ ```php
373
+ use GuzzleHttp\Promise\RejectedPromise;
374
+
375
+ $promise = new RejectedPromise('Error');
376
+
377
+ // Rejected callbacks are immediately invoked.
378
+ $promise->then(null, function ($reason) {
379
+ echo $reason;
380
+ });
381
+ ```
382
+
383
+
384
+ # Promise interop
385
+
386
+ This library works with foreign promises that have a `then` method. This means
387
+ you can use Guzzle promises with [React promises](https://github.com/reactphp/promise)
388
+ for example. When a foreign promise is returned inside of a then method
389
+ callback, promise resolution will occur recursively.
390
+
391
+ ```php
392
+ // Create a React promise
393
+ $deferred = new React\Promise\Deferred();
394
+ $reactPromise = $deferred->promise();
395
+
396
+ // Create a Guzzle promise that is fulfilled with a React promise.
397
+ $guzzlePromise = new \GuzzleHttp\Promise\Promise();
398
+ $guzzlePromise->then(function ($value) use ($reactPromise) {
399
+ // Do something something with the value...
400
+ // Return the React promise
401
+ return $reactPromise;
402
+ });
403
+ ```
404
+
405
+ Please note that wait and cancel chaining is no longer possible when forwarding
406
+ a foreign promise. You will need to wrap a third-party promise with a Guzzle
407
+ promise in order to utilize wait and cancel functions with foreign promises.
408
+
409
+
410
+ ## Event Loop Integration
411
+
412
+ In order to keep the stack size constant, Guzzle promises are resolved
413
+ asynchronously using a task queue. When waiting on promises synchronously, the
414
+ task queue will be automatically run to ensure that the blocking promise and
415
+ any forwarded promises are resolved. When using promises asynchronously in an
416
+ event loop, you will need to run the task queue on each tick of the loop. If
417
+ you do not run the task queue, then promises will not be resolved.
418
+
419
+ You can run the task queue using the `run()` method of the global task queue
420
+ instance.
421
+
422
+ ```php
423
+ // Get the global task queue
424
+ $queue = \GuzzleHttp\Promise\queue();
425
+ $queue->run();
426
+ ```
427
+
428
+ For example, you could use Guzzle promises with React using a periodic timer:
429
+
430
+ ```php
431
+ $loop = React\EventLoop\Factory::create();
432
+ $loop->addPeriodicTimer(0, [$queue, 'run']);
433
+ ```
434
+
435
+ *TODO*: Perhaps adding a `futureTick()` on each tick would be faster?
436
+
437
+
438
+ # Implementation notes
439
+
440
+
441
+ ## Promise resolution and chaining is handled iteratively
442
+
443
+ By shuffling pending handlers from one owner to another, promises are
444
+ resolved iteratively, allowing for "infinite" then chaining.
445
+
446
+ ```php
447
+ <?php
448
+ require 'vendor/autoload.php';
449
+
450
+ use GuzzleHttp\Promise\Promise;
451
+
452
+ $parent = new Promise();
453
+ $p = $parent;
454
+
455
+ for ($i = 0; $i < 1000; $i++) {
456
+ $p = $p->then(function ($v) {
457
+ // The stack size remains constant (a good thing)
458
+ echo xdebug_get_stack_depth() . ', ';
459
+ return $v + 1;
460
+ });
461
+ }
462
+
463
+ $parent->resolve(0);
464
+ var_dump($p->wait()); // int(1000)
465
+
466
+ ```
467
+
468
+ When a promise is fulfilled or rejected with a non-promise value, the promise
469
+ then takes ownership of the handlers of each child promise and delivers values
470
+ down the chain without using recursion.
471
+
472
+ When a promise is resolved with another promise, the original promise transfers
473
+ all of its pending handlers to the new promise. When the new promise is
474
+ eventually resolved, all of the pending handlers are delivered the forwarded
475
+ value.
476
+
477
+
478
+ ## A promise is the deferred.
479
+
480
+ Some promise libraries implement promises using a deferred object to represent
481
+ a computation and a promise object to represent the delivery of the result of
482
+ the computation. This is a nice separation of computation and delivery because
483
+ consumers of the promise cannot modify the value that will be eventually
484
+ delivered.
485
+
486
+ One side effect of being able to implement promise resolution and chaining
487
+ iteratively is that you need to be able for one promise to reach into the state
488
+ of another promise to shuffle around ownership of handlers. In order to achieve
489
+ this without making the handlers of a promise publicly mutable, a promise is
490
+ also the deferred value, allowing promises of the same parent class to reach
491
+ into and modify the private properties of promises of the same type. While this
492
+ does allow consumers of the value to modify the resolution or rejection of the
493
+ deferred, it is a small price to pay for keeping the stack size constant.
494
+
495
+ ```php
496
+ $promise = new Promise();
497
+ $promise->then(function ($value) { echo $value; });
498
+ // The promise is the deferred value, so you can deliver a value to it.
499
+ $promise->deliver('foo');
500
+ // prints "foo"
501
+ ```
app/api/Ctct/vendor/guzzlehttp/promises/composer.json ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "guzzlehttp/promises",
3
+ "type": "library",
4
+ "description": "Guzzle promises library",
5
+ "keywords": ["promise"],
6
+ "license": "MIT",
7
+ "authors": [
8
+ {
9
+ "name": "Michael Dowling",
10
+ "email": "mtdowling@gmail.com",
11
+ "homepage": "https://github.com/mtdowling"
12
+ }
13
+ ],
14
+ "require": {
15
+ "php": ">=5.5.0"
16
+ },
17
+ "require-dev": {
18
+ "phpunit/phpunit": "~4.0"
19
+ },
20
+ "autoload": {
21
+ "psr-4": {
22
+ "GuzzleHttp\\Promise\\": "src/"
23
+ },
24
+ "files": ["src/functions_include.php"]
25
+ },
26
+ "extra": {
27
+ "branch-alias": {
28
+ "dev-master": "1.0-dev"
29
+ }
30
+ }
31
+ }
app/api/Ctct/vendor/guzzlehttp/promises/phpunit.xml.dist ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <phpunit bootstrap="./tests/bootstrap.php"
3
+ colors="true">
4
+ <testsuites>
5
+ <testsuite>
6
+ <directory>tests</directory>
7
+ </testsuite>
8
+ </testsuites>
9
+ <filter>
10
+ <whitelist>
11
+ <directory suffix=".php">src</directory>
12
+ <exclude>
13
+ <directory suffix="Interface.php">src/</directory>
14
+ </exclude>
15
+ </whitelist>
16
+ </filter>
17
+ </phpunit>
app/api/Ctct/vendor/guzzlehttp/promises/src/AggregateException.php ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Promise;
3
+
4
+ /**
5
+ * Exception thrown when too many errors occur in the some() or any() methods.
6
+ */
7
+ class AggregateException extends RejectionException
8
+ {
9
+ public function __construct($msg, array $reasons)
10
+ {
11
+ parent::__construct(
12
+ $reasons,
13
+ sprintf('%s; %d rejected promises', $msg, count($reasons))
14
+ );
15
+ }
16
+ }
app/api/Ctct/vendor/guzzlehttp/promises/src/CancellationException.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Promise;
3
+
4
+ /**
5
+ * Exception that is set as the reason for a promise that has been cancelled.
6
+ */
7
+ class CancellationException extends RejectionException
8
+ {
9
+ }
app/api/Ctct/vendor/guzzlehttp/promises/src/EachPromise.php ADDED
@@ -0,0 +1,207 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Promise;
3
+
4
+ /**
5
+ * Represents a promise that iterates over many promises and invokes
6
+ * side-effect functions in the process.
7
+ */
8
+ class EachPromise implements PromisorInterface
9
+ {
10
+ private $pending = [];
11
+
12
+ /** @var \Iterator */
13
+ private $iterable;
14
+
15
+ /** @var callable|int */
16
+ private $concurrency;
17
+
18
+ /** @var callable */
19
+ private $onFulfilled;
20
+
21
+ /** @var callable */
22
+ private $onRejected;
23
+
24
+ /** @var Promise */
25
+ private $aggregate;
26
+
27
+ /**
28
+ * Configuration hash can include the following key value pairs:
29
+ *
30
+ * - fulfilled: (callable) Invoked when a promise fulfills. The function
31
+ * is invoked with three arguments: the fulfillment value, the index
32
+ * position from the iterable list of the promise, and the aggregate
33
+ * promise that manages all of the promises. The aggregate promise may
34
+ * be resolved from within the callback to short-circuit the promise.
35
+ * - rejected: (callable) Invoked when a promise is rejected. The
36
+ * function is invoked with three arguments: the rejection reason, the
37
+ * index position from the iterable list of the promise, and the
38
+ * aggregate promise that manages all of the promises. The aggregate
39
+ * promise may be resolved from within the callback to short-circuit
40
+ * the promise.
41
+ * - concurrency: (integer) Pass this configuration option to limit the
42
+ * allowed number of outstanding concurrently executing promises,
43
+ * creating a capped pool of promises. There is no limit by default.
44
+ *
45
+ * @param mixed $iterable Promises or values to iterate.
46
+ * @param array $config Configuration options
47
+ */
48
+ public function __construct($iterable, array $config = [])
49
+ {
50
+ $this->iterable = iter_for($iterable);
51
+
52
+ if (isset($config['concurrency'])) {
53
+ $this->concurrency = $config['concurrency'];
54
+ }
55
+
56
+ if (isset($config['fulfilled'])) {
57
+ $this->onFulfilled = $config['fulfilled'];
58
+ }
59
+
60
+ if (isset($config['rejected'])) {
61
+ $this->onRejected = $config['rejected'];
62
+ }
63
+ }
64
+
65
+ public function promise()
66
+ {
67
+ if ($this->aggregate) {
68
+ return $this->aggregate;
69
+ }
70
+
71
+ try {
72
+ $this->createPromise();
73
+ $this->iterable->rewind();
74
+ $this->refillPending();
75
+ } catch (\Exception $e) {
76
+ $this->aggregate->reject($e);
77
+ }
78
+
79
+ return $this->aggregate;
80
+ }
81
+
82
+ private function createPromise()
83
+ {
84
+ $this->aggregate = new Promise(function () {
85
+ reset($this->pending);
86
+ if (empty($this->pending) && !$this->iterable->valid()) {
87
+ $this->aggregate->resolve(null);
88
+ return;
89
+ }
90
+
91
+ // Consume a potentially fluctuating list of promises while
92
+ // ensuring that indexes are maintained (precluding array_shift).
93
+ while ($promise = current($this->pending)) {
94
+ next($this->pending);
95
+ $promise->wait();
96
+ if ($this->aggregate->getState() !== PromiseInterface::PENDING) {
97
+ return;
98
+ }
99
+ }
100
+ });
101
+
102
+ // Clear the references when the promise is resolved.
103
+ $clearFn = function () {
104
+ $this->iterable = $this->concurrency = $this->pending = null;
105
+ $this->onFulfilled = $this->onRejected = null;
106
+ };
107
+
108
+ $this->aggregate->then($clearFn, $clearFn);
109
+ }
110
+
111
+ private function refillPending()
112
+ {
113
+ if (!$this->concurrency) {
114
+ // Add all pending promises.
115
+ while ($this->addPending() && $this->advanceIterator());
116
+ return;
117
+ }
118
+
119
+ // Add only up to N pending promises.
120
+ $concurrency = is_callable($this->concurrency)
121
+ ? call_user_func($this->concurrency, count($this->pending))
122
+ : $this->concurrency;
123
+ $concurrency = max($concurrency - count($this->pending), 0);
124
+ // Concurrency may be set to 0 to disallow new promises.
125
+ if (!$concurrency) {
126
+ return;
127
+ }
128
+ // Add the first pending promise.
129
+ $this->addPending();
130
+ // Note this is special handling for concurrency=1 so that we do
131
+ // not advance the iterator after adding the first promise. This
132
+ // helps work around issues with generators that might not have the
133
+ // next value to yield until promise callbacks are called.
134
+ while (--$concurrency
135
+ && $this->advanceIterator()
136
+ && $this->addPending());
137
+ }
138
+
139
+ private function addPending()
140
+ {
141
+ if (!$this->iterable || !$this->iterable->valid()) {
142
+ return false;
143
+ }
144
+
145
+ $promise = promise_for($this->iterable->current());
146
+ $idx = $this->iterable->key();
147
+
148
+ $this->pending[$idx] = $promise->then(
149
+ function ($value) use ($idx) {
150
+ if ($this->onFulfilled) {
151
+ call_user_func(
152
+ $this->onFulfilled, $value, $idx, $this->aggregate
153
+ );
154
+ }
155
+ $this->step($idx);
156
+ },
157
+ function ($reason) use ($idx) {
158
+ if ($this->onRejected) {
159
+ call_user_func(
160
+ $this->onRejected, $reason, $idx, $this->aggregate
161
+ );
162
+ }
163
+ $this->step($idx);
164
+ }
165
+ );
166
+
167
+ return true;
168
+ }
169
+
170
+ private function advanceIterator()
171
+ {
172
+ try {
173
+ $this->iterable->next();
174
+ return true;
175
+ } catch (\Exception $e) {
176
+ $this->aggregate->reject($e);
177
+ return false;
178
+ }
179
+ }
180
+
181
+ private function step($idx)
182
+ {
183
+ // If the promise was already resolved, then ignore this step.
184
+ if ($this->aggregate->getState() !== PromiseInterface::PENDING) {
185
+ return;
186
+ }
187
+
188
+ unset($this->pending[$idx]);
189
+ $this->advanceIterator();
190
+
191
+ if (!$this->checkIfFinished()) {
192
+ // Add more pending promises if possible.
193
+ $this->refillPending();
194
+ }
195
+ }
196
+
197
+ private function checkIfFinished()
198
+ {
199
+ if (!$this->pending && !$this->iterable->valid()) {
200
+ // Resolve the promise if there's nothing left to do.
201
+ $this->aggregate->resolve(null);
202
+ return true;
203
+ }
204
+
205
+ return false;
206
+ }
207
+ }
app/api/Ctct/vendor/guzzlehttp/promises/src/FulfilledPromise.php ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Promise;
3
+
4
+ /**
5
+ * A promise that has been fulfilled.
6
+ *
7
+ * Thenning off of this promise will invoke the onFulfilled callback
8
+ * immediately and ignore other callbacks.
9
+ */
10
+ class FulfilledPromise implements PromiseInterface
11
+ {
12
+ private $value;
13
+
14
+ public function __construct($value)
15
+ {
16
+ if (method_exists($value, 'then')) {
17
+ throw new \InvalidArgumentException(
18
+ 'You cannot create a FulfilledPromise with a promise.');
19
+ }
20
+
21
+ $this->value = $value;
22
+ }
23
+
24
+ public function then(
25
+ callable $onFulfilled = null,
26
+ callable $onRejected = null
27
+ ) {
28
+ // Return itself if there is no onFulfilled function.
29
+ if (!$onFulfilled) {
30
+ return $this;
31
+ }
32
+
33
+ $queue = queue();
34
+ $p = new Promise([$queue, 'run']);
35
+ $value = $this->value;
36
+ $queue->add(static function () use ($p, $value, $onFulfilled) {
37
+ if ($p->getState() === self::PENDING) {
38
+ try {
39
+ $p->resolve($onFulfilled($value));
40
+ } catch (\Exception $e) {
41
+ $p->reject($e);
42
+ }
43
+ }
44
+ });
45
+
46
+ return $p;
47
+ }
48
+
49
+ public function otherwise(callable $onRejected)
50
+ {
51
+ return $this->then(null, $onRejected);
52
+ }
53
+
54
+ public function wait($unwrap = true, $defaultDelivery = null)
55
+ {
56
+ return $unwrap ? $this->value : null;
57
+ }
58
+
59
+ public function getState()
60
+ {
61
+ return self::FULFILLED;
62
+ }
63
+
64
+ public function resolve($value)
65
+ {
66
+ if ($value !== $this->value) {
67
+ throw new \LogicException("Cannot resolve a fulfilled promise");
68
+ }
69
+ }
70
+
71
+ public function reject($reason)
72
+ {
73
+ throw new \LogicException("Cannot reject a fulfilled promise");
74
+ }
75
+
76
+ public function cancel()
77
+ {
78
+ // pass
79
+ }
80
+ }
app/api/Ctct/vendor/guzzlehttp/promises/src/Promise.php ADDED
@@ -0,0 +1,268 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Promise;
3
+
4
+ /**
5
+ * Promises/A+ implementation that avoids recursion when possible.
6
+ *
7
+ * @link https://promisesaplus.com/
8
+ */
9
+ class Promise implements PromiseInterface
10
+ {
11
+ private $state = self::PENDING;
12
+ private $result;
13
+ private $cancelFn;
14
+ private $waitFn;
15
+ private $waitList;
16
+ private $handlers = [];
17
+
18
+ /**
19
+ * @param callable $waitFn Fn that when invoked resolves the promise.
20
+ * @param callable $cancelFn Fn that when invoked cancels the promise.
21
+ */
22
+ public function __construct(
23
+ callable $waitFn = null,
24
+ callable $cancelFn = null
25
+ ) {
26
+ $this->waitFn = $waitFn;
27
+ $this->cancelFn = $cancelFn;
28
+ }
29
+
30
+ public function then(
31
+ callable $onFulfilled = null,
32
+ callable $onRejected = null
33
+ ) {
34
+ if ($this->state === self::PENDING) {
35
+ $p = new Promise(null, [$this, 'cancel']);
36
+ $this->handlers[] = [$p, $onFulfilled, $onRejected];
37
+ $p->waitList = $this->waitList;
38
+ $p->waitList[] = $this;
39
+ return $p;
40
+ }
41
+
42
+ // Return a fulfilled promise and immediately invoke any callbacks.
43
+ if ($this->state === self::FULFILLED) {
44
+ return $onFulfilled
45
+ ? promise_for($this->result)->then($onFulfilled)
46
+ : promise_for($this->result);
47
+ }
48
+
49
+ // It's either cancelled or rejected, so return a rejected promise
50
+ // and immediately invoke any callbacks.
51
+ $rejection = rejection_for($this->result);
52
+ return $onRejected ? $rejection->then(null, $onRejected) : $rejection;
53
+ }
54
+
55
+ public function otherwise(callable $onRejected)
56
+ {
57
+ return $this->then(null, $onRejected);
58
+ }
59
+
60
+ public function wait($unwrap = true)
61
+ {
62
+ $this->waitIfPending();
63
+
64
+ if (!$unwrap) {
65
+ return null;
66
+ }
67
+
68
+ if ($this->result instanceof PromiseInterface) {
69
+ return $this->result->wait($unwrap);
70
+ } elseif ($this->state === self::FULFILLED) {
71
+ return $this->result;
72
+ } else {
73
+ // It's rejected so "unwrap" and throw an exception.
74
+ throw exception_for($this->result);
75
+ }
76
+ }
77
+
78
+ public function getState()
79
+ {
80
+ return $this->state;
81
+ }
82
+
83
+ public function cancel()
84
+ {
85
+ if ($this->state !== self::PENDING) {
86
+ return;
87
+ }
88
+
89
+ $this->waitFn = $this->waitList = null;
90
+
91
+ if ($this->cancelFn) {
92
+ $fn = $this->cancelFn;
93
+ $this->cancelFn = null;
94
+ try {
95
+ $fn();
96
+ } catch (\Exception $e) {
97
+ $this->reject($e);
98
+ }
99
+ }
100
+
101
+ // Reject the promise only if it wasn't rejected in a then callback.
102
+ if ($this->state === self::PENDING) {
103
+ $this->reject(new CancellationException('Promise has been cancelled'));
104
+ }
105
+ }
106
+
107
+ public function resolve($value)
108
+ {
109
+ $this->settle(self::FULFILLED, $value);
110
+ }
111
+
112
+ public function reject($reason)
113
+ {
114
+ $this->settle(self::REJECTED, $reason);
115
+ }
116
+
117
+ private function settle($state, $value)
118
+ {
119
+ if ($this->state !== self::PENDING) {
120
+ // Ignore calls with the same resolution.
121
+ if ($state === $this->state && $value === $this->result) {
122
+ return;
123
+ }
124
+ throw $this->state === $state
125
+ ? new \LogicException("The promise is already {$state}.")
126
+ : new \LogicException("Cannot change a {$this->state} promise to {$state}");
127
+ }
128
+
129
+ if ($value === $this) {
130
+ throw new \LogicException('Cannot fulfill or reject a promise with itself');
131
+ }
132
+
133
+ // Clear out the state of the promise but stash the handlers.
134
+ $this->state = $state;
135
+ $this->result = $value;
136
+ $handlers = $this->handlers;
137
+ $this->handlers = null;
138
+ $this->waitList = $this->waitFn = null;
139
+ $this->cancelFn = null;
140
+
141
+ if (!$handlers) {
142
+ return;
143
+ }
144
+
145
+ // If the value was not a settled promise or a thenable, then resolve
146
+ // it in the task queue using the correct ID.
147
+ if (!method_exists($value, 'then')) {
148
+ $id = $state === self::FULFILLED ? 1 : 2;
149
+ // It's a success, so resolve the handlers in the queue.
150
+ queue()->add(static function () use ($id, $value, $handlers) {
151
+ foreach ($handlers as $handler) {
152
+ self::callHandler($id, $value, $handler);
153
+ }
154
+ });
155
+ } elseif ($value instanceof Promise
156
+ && $value->getState() === self::PENDING
157
+ ) {
158
+ // We can just merge our handlers onto the next promise.
159
+ $value->handlers = array_merge($value->handlers, $handlers);
160
+ } else {
161
+ // Resolve the handlers when the forwarded promise is resolved.
162
+ $value->then(
163
+ static function ($value) use ($handlers) {
164
+ foreach ($handlers as $handler) {
165
+ self::callHandler(1, $value, $handler);
166
+ }
167
+ },
168
+ static function ($reason) use ($handlers) {
169
+ foreach ($handlers as $handler) {
170
+ self::callHandler(2, $reason, $handler);
171
+ }
172
+ }
173
+ );
174
+ }
175
+ }
176
+
177
+ /**
178
+ * Call a stack of handlers using a specific callback index and value.
179
+ *
180
+ * @param int $index 1 (resolve) or 2 (reject).
181
+ * @param mixed $value Value to pass to the callback.
182
+ * @param array $handler Array of handler data (promise and callbacks).
183
+ *
184
+ * @return array Returns the next group to resolve.
185
+ */
186
+ private static function callHandler($index, $value, array $handler)
187
+ {
188
+ /** @var PromiseInterface $promise */
189
+ $promise = $handler[0];
190
+
191
+ // The promise may have been cancelled or resolved before placing
192
+ // this thunk in the queue.
193
+ if ($promise->getState() !== self::PENDING) {
194
+ return;
195
+ }
196
+
197
+ try {
198
+ if (isset($handler[$index])) {
199
+ $promise->resolve($handler[$index]($value));
200
+ } elseif ($index === 1) {
201
+ // Forward resolution values as-is.
202
+ $promise->resolve($value);
203
+ } else {
204
+ // Forward rejections down the chain.
205
+ $promise->reject($value);
206
+ }
207
+ } catch (\Exception $reason) {
208
+ $promise->reject($reason);
209
+ }
210
+ }
211
+
212
+ private function waitIfPending()
213
+ {
214
+ if ($this->state !== self::PENDING) {
215
+ return;
216
+ } elseif ($this->waitFn) {
217
+ $this->invokeWaitFn();
218
+ } elseif ($this->waitList) {
219
+ $this->invokeWaitList();
220
+ } else {
221
+ // If there's not wait function, then reject the promise.
222
+ $this->reject('Cannot wait on a promise that has '
223
+ . 'no internal wait function. You must provide a wait '
224
+ . 'function when constructing the promise to be able to '
225
+ . 'wait on a promise.');
226
+ }
227
+
228
+ queue()->run();
229
+
230
+ if ($this->state === self::PENDING) {
231
+ $this->reject('Invoking the wait callback did not resolve the promise');
232
+ }
233
+ }
234
+
235
+ private function invokeWaitFn()
236
+ {
237
+ try {
238
+ $wfn = $this->waitFn;
239
+ $this->waitFn = null;
240
+ $wfn(true);
241
+ } catch (\Exception $reason) {
242
+ if ($this->state === self::PENDING) {
243
+ // The promise has not been resolved yet, so reject the promise
244
+ // with the exception.
245
+ $this->reject($reason);
246
+ } else {
247
+ // The promise was already resolved, so there's a problem in
248
+ // the application.
249
+ throw $reason;
250
+ }
251
+ }
252
+ }
253
+
254
+ private function invokeWaitList()
255
+ {
256
+ $waitList = $this->waitList;
257
+ $this->waitList = null;
258
+
259
+ foreach ($waitList as $result) {
260
+ descend:
261
+ $result->waitIfPending();
262
+ if ($result->result instanceof Promise) {
263
+ $result = $result->result;
264
+ goto descend;
265
+ }
266
+ }
267
+ }
268
+ }
app/api/Ctct/vendor/guzzlehttp/promises/src/PromiseInterface.php ADDED
@@ -0,0 +1,93 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Promise;
3
+
4
+ /**
5
+ * A promise represents the eventual result of an asynchronous operation.
6
+ *
7
+ * The primary way of interacting with a promise is through its then method,
8
+ * which registers callbacks to receive either a promise’s eventual value or
9
+ * the reason why the promise cannot be fulfilled.
10
+ *
11
+ * @link https://promisesaplus.com/
12
+ */
13
+ interface PromiseInterface
14
+ {
15
+ const PENDING = 'pending';
16
+ const FULFILLED = 'fulfilled';
17
+ const REJECTED = 'rejected';
18
+
19
+ /**
20
+ * Appends fulfillment and rejection handlers to the promise, and returns
21
+ * a new promise resolving to the return value of the called handler.
22
+ *
23
+ * @param callable $onFulfilled Invoked when the promise fulfills.
24
+ * @param callable $onRejected Invoked when the promise is rejected.
25
+ *
26
+ * @return PromiseInterface
27
+ */
28
+ public function then(
29
+ callable $onFulfilled = null,
30
+ callable $onRejected = null
31
+ );
32
+
33
+ /**
34
+ * Appends a rejection handler callback to the promise, and returns a new
35
+ * promise resolving to the return value of the callback if it is called,
36
+ * or to its original fulfillment value if the promise is instead
37
+ * fulfilled.
38
+ *
39
+ * @param callable $onRejected Invoked when the promise is rejected.
40
+ *
41
+ * @return PromiseInterface
42
+ */
43
+ public function otherwise(callable $onRejected);
44
+
45
+ /**
46
+ * Get the state of the promise ("pending", "rejected", or "fulfilled").
47
+ *
48
+ * The three states can be checked against the constants defined on
49
+ * PromiseInterface: PENDING, FULFILLED, and REJECTED.
50
+ *
51
+ * @return string
52
+ */
53
+ public function getState();
54
+
55
+ /**
56
+ * Resolve the promise with the given value.
57
+ *
58
+ * @param mixed $value
59
+ * @throws \RuntimeException if the promise is already resolved.
60
+ */
61
+ public function resolve($value);
62
+
63
+ /**
64
+ * Reject the promise with the given reason.
65
+ *
66
+ * @param mixed $reason
67
+ * @throws \RuntimeException if the promise is already resolved.
68
+ */
69
+ public function reject($reason);
70
+
71
+ /**
72
+ * Cancels the promise if possible.
73
+ *
74
+ * @link https://github.com/promises-aplus/cancellation-spec/issues/7
75
+ */
76
+ public function cancel();
77
+
78
+ /**
79
+ * Waits until the promise completes if possible.
80
+ *
81
+ * Pass $unwrap as true to unwrap the result of the promise, either
82
+ * returning the resolved value or throwing the rejected exception.
83
+ *
84
+ * If the promise cannot be waited on, then the promise will be rejected.
85
+ *
86
+ * @param bool $unwrap
87
+ *
88
+ * @return mixed
89
+ * @throws \LogicException if the promise has no wait function or if the
90
+ * promise does not settle after waiting.
91
+ */
92
+ public function wait($unwrap = true);
93
+ }
app/api/Ctct/vendor/guzzlehttp/promises/src/PromisorInterface.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Promise;
3
+
4
+ /**
5
+ * Interface used with classes that return a promise.
6
+ */
7
+ interface PromisorInterface
8
+ {
9
+ /**
10
+ * Returns a promise.
11
+ *
12
+ * @return PromiseInterface
13
+ */
14
+ public function promise();
15
+ }
app/api/Ctct/vendor/guzzlehttp/promises/src/RejectedPromise.php ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Promise;
3
+
4
+ /**
5
+ * A promise that has been rejected.
6
+ *
7
+ * Thenning off of this promise will invoke the onRejected callback
8
+ * immediately and ignore other callbacks.
9
+ */
10
+ class RejectedPromise implements PromiseInterface
11
+ {
12
+ private $reason;
13
+
14
+ public function __construct($reason)
15
+ {
16
+ if (method_exists($reason, 'then')) {
17
+ throw new \InvalidArgumentException(
18
+ 'You cannot create a RejectedPromise with a promise.');
19
+ }
20
+
21
+ $this->reason = $reason;
22
+ }
23
+
24
+ public function then(
25
+ callable $onFulfilled = null,
26
+ callable $onRejected = null
27
+ ) {
28
+ // If there's no onRejected callback then just return self.
29
+ if (!$onRejected) {
30
+ return $this;
31
+ }
32
+
33
+ $queue = queue();
34
+ $reason = $this->reason;
35
+ $p = new Promise([$queue, 'run']);
36
+ $queue->add(static function () use ($p, $reason, $onRejected) {
37
+ if ($p->getState() === self::PENDING) {
38
+ try {
39
+ // Return a resolved promise if onRejected does not throw.
40
+ $p->resolve($onRejected($reason));
41
+ } catch (\Exception $e) {
42
+ // onRejected threw, so return a rejected promise.
43
+ $p->reject($e);
44
+ }
45
+ }
46
+ });
47
+
48
+ return $p;
49
+ }
50
+
51
+ public function otherwise(callable $onRejected)
52
+ {
53
+ return $this->then(null, $onRejected);
54
+ }
55
+
56
+ public function wait($unwrap = true, $defaultDelivery = null)
57
+ {
58
+ if ($unwrap) {
59
+ throw exception_for($this->reason);
60
+ }
61
+ }
62
+
63
+ public function getState()
64
+ {
65
+ return self::REJECTED;
66
+ }
67
+
68
+ public function resolve($value)
69
+ {
70
+ throw new \LogicException("Cannot resolve a rejected promise");
71
+ }
72
+
73
+ public function reject($reason)
74
+ {
75
+ if ($reason !== $this->reason) {
76
+ throw new \LogicException("Cannot reject a rejected promise");
77
+ }
78
+ }
79
+
80
+ public function cancel()
81
+ {
82
+ // pass
83
+ }
84
+ }
app/api/Ctct/vendor/guzzlehttp/promises/src/RejectionException.php ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Promise;
3
+
4
+ /**
5
+ * A special exception that is thrown when waiting on a rejected promise.
6
+ *
7
+ * The reason value is available via the getReason() method.
8
+ */
9
+ class RejectionException extends \RuntimeException
10
+ {
11
+ /** @var mixed Rejection reason. */
12
+ private $reason;
13
+
14
+ /**
15
+ * @param mixed $reason Rejection reason.
16
+ * @param string $description Optional description
17
+ */
18
+ public function __construct($reason, $description = null)
19
+ {
20
+ $this->reason = $reason;
21
+
22
+ $message = 'The promise was rejected';
23
+
24
+ if ($description) {
25
+ $message .= ' with reason: ' . $description;
26
+ } elseif (is_string($reason)
27
+ || (is_object($reason) && method_exists($reason, '__toString'))
28
+ ) {
29
+ $message .= ' with reason: ' . $this->reason;
30
+ } elseif ($reason instanceof \JsonSerializable) {
31
+ $message .= ' with reason: '
32
+ . json_encode($this->reason, JSON_PRETTY_PRINT);
33
+ }
34
+
35
+ parent::__construct($message);
36
+ }
37
+
38
+ /**
39
+ * Returns the rejection reason.
40
+ *
41
+ * @return mixed
42
+ */
43
+ public function getReason()
44
+ {
45
+ return $this->reason;
46
+ }
47
+ }
app/api/Ctct/vendor/guzzlehttp/promises/src/TaskQueue.php ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Promise;
3
+
4
+ /**
5
+ * A task queue that executes tasks in a FIFO order.
6
+ *
7
+ * This task queue class is used to settle promises asynchronously and
8
+ * maintains a constant stack size. You can use the task queue asynchronously
9
+ * by calling the `run()` function of the global task queue in an event loop.
10
+ *
11
+ * GuzzleHttp\Promise\queue()->run();
12
+ */
13
+ class TaskQueue
14
+ {
15
+ private $enableShutdown = true;
16
+ private $queue = [];
17
+
18
+ public function __construct($withShutdown = true)
19
+ {
20
+ if ($withShutdown) {
21
+ register_shutdown_function(function () {
22
+ if ($this->enableShutdown) {
23
+ // Only run the tasks if an E_ERROR didn't occur.
24
+ $err = error_get_last();
25
+ if (!$err || ($err['type'] ^ E_ERROR)) {
26
+ $this->run();
27
+ }
28
+ }
29
+ });
30
+ }
31
+ }
32
+
33
+ /**
34
+ * Returns true if the queue is empty.
35
+ *
36
+ * @return bool
37
+ */
38
+ public function isEmpty()
39
+ {
40
+ return !$this->queue;
41
+ }
42
+
43
+ /**
44
+ * Adds a task to the queue that will be executed the next time run is
45
+ * called.
46
+ *
47
+ * @param callable $task
48
+ */
49
+ public function add(callable $task)
50
+ {
51
+ $this->queue[] = $task;
52
+ }
53
+
54
+ /**
55
+ * Execute all of the pending task in the queue.
56
+ */
57
+ public function run()
58
+ {
59
+ while ($task = array_shift($this->queue)) {
60
+ $task();
61
+ }
62
+ }
63
+
64
+ /**
65
+ * The task queue will be run and exhausted by default when the process
66
+ * exits IFF the exit is not the result of a PHP E_ERROR error.
67
+ *
68
+ * You can disable running the automatic shutdown of the queue by calling
69
+ * this function. If you disable the task queue shutdown process, then you
70
+ * MUST either run the task queue (as a result of running your event loop
71
+ * or manually using the run() method) or wait on each outstanding promise.
72
+ *
73
+ * Note: This shutdown will occur before any destructors are triggered.
74
+ */
75
+ public function disableShutdown()
76
+ {
77
+ $this->enableShutdown = false;
78
+ }
79
+ }
app/api/Ctct/vendor/guzzlehttp/promises/src/functions.php ADDED
@@ -0,0 +1,495 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Promise;
3
+
4
+ /**
5
+ * Get the global task queue used for promise resolution.
6
+ *
7
+ * This task queue MUST be run in an event loop in order for promises to be
8
+ * settled asynchronously. It will be automatically run when synchronously
9
+ * waiting on a promise.
10
+ *
11
+ * <code>
12
+ * while ($eventLoop->isRunning()) {
13
+ * GuzzleHttp\Promise\queue()->run();
14
+ * }
15
+ * </code>
16
+ *
17
+ * @return TaskQueue
18
+ */
19
+ function queue()
20
+ {
21
+ static $queue;
22
+
23
+ if (!$queue) {
24
+ $queue = new TaskQueue();
25
+ }
26
+
27
+ return $queue;
28
+ }
29
+
30
+ /**
31
+ * Adds a function to run in the task queue when it is next `run()` and returns
32
+ * a promise that is fulfilled or rejected with the result.
33
+ *
34
+ * @param callable $task Task function to run.
35
+ *
36
+ * @return PromiseInterface
37
+ */
38
+ function task(callable $task)
39
+ {
40
+ $queue = queue();
41
+ $promise = new Promise([$queue, 'run']);
42
+ $queue->add(function () use ($task, $promise) {
43
+ try {
44
+ $promise->resolve($task());
45
+ } catch (\Exception $e) {
46
+ $promise->reject($e);
47
+ }
48
+ });
49
+
50
+ return $promise;
51
+ }
52
+
53
+ /**
54
+ * Creates a promise for a value if the value is not a promise.
55
+ *
56
+ * @param mixed $value Promise or value.
57
+ *
58
+ * @return PromiseInterface
59
+ */
60
+ function promise_for($value)
61
+ {
62
+ if ($value instanceof PromiseInterface) {
63
+ return $value;
64
+ }
65
+
66
+ // Return a Guzzle promise that shadows the given promise.
67
+ if (method_exists($value, 'then')) {
68
+ $wfn = method_exists($value, 'wait') ? [$value, 'wait'] : null;
69
+ $cfn = method_exists($value, 'cancel') ? [$value, 'cancel'] : null;
70
+ $promise = new Promise($wfn, $cfn);
71
+ $value->then([$promise, 'resolve'], [$promise, 'reject']);
72
+ return $promise;
73
+ }
74
+
75
+ return new FulfilledPromise($value);
76
+ }
77
+
78
+ /**
79
+ * Creates a rejected promise for a reason if the reason is not a promise. If
80
+ * the provided reason is a promise, then it is returned as-is.
81
+ *
82
+ * @param mixed $reason Promise or reason.
83
+ *
84
+ * @return PromiseInterface
85
+ */
86
+ function rejection_for($reason)
87
+ {
88
+ if ($reason instanceof PromiseInterface) {
89
+ return $reason;
90
+ }
91
+
92
+ return new RejectedPromise($reason);
93
+ }
94
+
95
+ /**
96
+ * Create an exception for a rejected promise value.
97
+ *
98
+ * @param mixed $reason
99
+ *
100
+ * @return \Exception
101
+ */
102
+ function exception_for($reason)
103
+ {
104
+ return $reason instanceof \Exception
105
+ ? $reason
106
+ : new RejectionException($reason);
107
+ }
108
+
109
+ /**
110
+ * Returns an iterator for the given value.
111
+ *
112
+ * @param mixed $value
113
+ *
114
+ * @return \Iterator
115
+ */
116
+ function iter_for($value)
117
+ {
118
+ if ($value instanceof \Iterator) {
119
+ return $value;
120
+ } elseif (is_array($value)) {
121
+ return new \ArrayIterator($value);
122
+ } else {
123
+ return new \ArrayIterator([$value]);
124
+ }
125
+ }
126
+
127
+ /**
128
+ * Synchronously waits on a promise to resolve and returns an inspection state
129
+ * array.
130
+ *
131
+ * Returns a state associative array containing a "state" key mapping to a
132
+ * valid promise state. If the state of the promise is "fulfilled", the array
133
+ * will contain a "value" key mapping to the fulfilled value of the promise. If
134
+ * the promise is rejected, the array will contain a "reason" key mapping to
135
+ * the rejection reason of the promise.
136
+ *
137
+ * @param PromiseInterface $promise Promise or value.
138
+ *
139
+ * @return array
140
+ */
141
+ function inspect(PromiseInterface $promise)
142
+ {
143
+ try {
144
+ return [
145
+ 'state' => PromiseInterface::FULFILLED,
146
+ 'value' => $promise->wait()
147
+ ];
148
+ } catch (RejectionException $e) {
149
+ return ['state' => 'rejected', 'reason' => $e->getReason()];
150
+ } catch (\Exception $e) {
151
+ return ['state' => 'rejected', 'reason' => $e];
152
+ }
153
+ }
154
+
155
+ /**
156
+ * Waits on all of the provided promises, but does not unwrap rejected promises
157
+ * as thrown exception.
158
+ *
159
+ * Returns an array of inspection state arrays.
160
+ *
161
+ * @param PromiseInterface[] $promises Traversable of promises to wait upon.
162
+ *
163
+ * @return array
164
+ * @see GuzzleHttp\Promise\inspect for the inspection state array format.
165
+ */
166
+ function inspect_all($promises)
167
+ {
168
+ $results = [];
169
+ foreach ($promises as $key => $promise) {
170
+ $results[$key] = inspect($promise);
171
+ }
172
+
173
+ return $results;
174
+ }
175
+
176
+ /**
177
+ * Waits on all of the provided promises and returns the fulfilled values.
178
+ *
179
+ * Returns an array that contains the value of each promise (in the same order
180
+ * the promises were provided). An exception is thrown if any of the promises
181
+ * are rejected.
182
+ *
183
+ * @param mixed $promises Iterable of PromiseInterface objects to wait on.
184
+ *
185
+ * @return array
186
+ * @throws \Exception on error
187
+ */
188
+ function unwrap($promises)
189
+ {
190
+ $results = [];
191
+ foreach ($promises as $key => $promise) {
192
+ $results[$key] = $promise->wait();
193
+ }
194
+
195
+ return $results;
196
+ }
197
+
198
+ /**
199
+ * Given an array of promises, return a promise that is fulfilled when all the
200
+ * items in the array are fulfilled.
201
+ *
202
+ * The promise's fulfillment value is an array with fulfillment values at
203
+ * respective positions to the original array. If any promise in the array
204
+ * rejects, the returned promise is rejected with the rejection reason.
205
+ *
206
+ * @param mixed $promises Promises or values.
207
+ *
208
+ * @return Promise
209
+ */
210
+ function all($promises)
211
+ {
212
+ $results = [];
213
+ return each(
214
+ $promises,
215
+ function ($value, $idx) use (&$results) {
216
+ $results[$idx] = $value;
217
+ },
218
+ function ($reason, $idx, Promise $aggregate) {
219
+ $aggregate->reject($reason);
220
+ }
221
+ )->then(function () use (&$results) {
222
+ ksort($results);
223
+ return $results;
224
+ });
225
+ }
226
+
227
+ /**
228
+ * Initiate a competitive race between multiple promises or values (values will
229
+ * become immediately fulfilled promises).
230
+ *
231
+ * When count amount of promises have been fulfilled, the returned promise is
232
+ * fulfilled with an array that contains the fulfillment values of the winners
233
+ * in order of resolution.
234
+ *
235
+ * This prommise is rejected with a {@see GuzzleHttp\Promise\AggregateException}
236
+ * if the number of fulfilled promises is less than the desired $count.
237
+ *
238
+ * @param int $count Total number of promises.
239
+ * @param mixed $promises Promises or values.
240
+ *
241
+ * @return Promise
242
+ */
243
+ function some($count, $promises)
244
+ {
245
+ $results = [];
246
+ $rejections = [];
247
+
248
+ return each(
249
+ $promises,
250
+ function ($value, $idx, PromiseInterface $p) use (&$results, $count) {
251
+ if ($p->getState() !== PromiseInterface::PENDING) {
252
+ return;
253
+ }
254
+ $results[$idx] = $value;
255
+ if (count($results) >= $count) {
256
+ $p->resolve(null);
257
+ }
258
+ },
259
+ function ($reason) use (&$rejections) {
260
+ $rejections[] = $reason;
261
+ }
262
+ )->then(
263
+ function () use (&$results, &$rejections, $count) {
264
+ if (count($results) !== $count) {
265
+ throw new AggregateException(
266
+ 'Not enough promises to fulfill count',
267
+ $rejections
268
+ );
269
+ }
270
+ ksort($results);
271
+ return array_values($results);
272
+ }
273
+ );
274
+ }
275
+
276
+ /**
277
+ * Like some(), with 1 as count. However, if the promise fulfills, the
278
+ * fulfillment value is not an array of 1 but the value directly.
279
+ *
280
+ * @param mixed $promises Promises or values.
281
+ *
282
+ * @return PromiseInterface
283
+ */
284
+ function any($promises)
285
+ {
286
+ return some(1, $promises)->then(function ($values) { return $values[0]; });
287
+ }
288
+
289
+ /**
290
+ * Returns a promise that is fulfilled when all of the provided promises have
291
+ * been fulfilled or rejected.
292
+ *
293
+ * The returned promise is fulfilled with an array of inspection state arrays.
294
+ *
295
+ * @param mixed $promises Promises or values.
296
+ *
297
+ * @return Promise
298
+ * @see GuzzleHttp\Promise\inspect for the inspection state array format.
299
+ */
300
+ function settle($promises)
301
+ {
302
+ $results = [];
303
+
304
+ return each(
305
+ $promises,
306
+ function ($value, $idx) use (&$results) {
307
+ $results[$idx] = ['state' => 'fulfilled', 'value' => $value];
308
+ },
309
+ function ($reason, $idx) use (&$results) {
310
+ $results[$idx] = ['state' => 'rejected', 'reason' => $reason];
311
+ }
312
+ )->then(function () use (&$results) {
313
+ ksort($results);
314
+ return $results;
315
+ });
316
+ }
317
+
318
+ /**
319
+ * Given an iterator that yields promises or values, returns a promise that is
320
+ * fulfilled with a null value when the iterator has been consumed or the
321
+ * aggregate promise has been fulfilled or rejected.
322
+ *
323
+ * $onFulfilled is a function that accepts the fulfilled value, iterator
324
+ * index, and the aggregate promise. The callback can invoke any necessary side
325
+ * effects and choose to resolve or reject the aggregate promise if needed.
326
+ *
327
+ * $onRejected is a function that accepts the rejection reason, iterator
328
+ * index, and the aggregate promise. The callback can invoke any necessary side
329
+ * effects and choose to resolve or reject the aggregate promise if needed.
330
+ *
331
+ * @param mixed $iterable Iterator or array to iterate over.
332
+ * @param callable $onFulfilled
333
+ * @param callable $onRejected
334
+ *
335
+ * @return Promise
336
+ */
337
+ function each(
338
+ $iterable,
339
+ callable $onFulfilled = null,
340
+ callable $onRejected = null
341
+ ) {
342
+ return (new EachPromise($iterable, [
343
+ 'fulfilled' => $onFulfilled,
344
+ 'rejected' => $onRejected
345
+ ]))->promise();
346
+ }
347
+
348
+ /**
349
+ * Like each, but only allows a certain number of outstanding promises at any
350
+ * given time.
351
+ *
352
+ * $concurrency may be an integer or a function that accepts the number of
353
+ * pending promises and returns a numeric concurrency limit value to allow for
354
+ * dynamic a concurrency size.
355
+ *
356
+ * @param mixed $iterable
357
+ * @param int|callable $concurrency
358
+ * @param callable $onFulfilled
359
+ * @param callable $onRejected
360
+ *
361
+ * @return mixed
362
+ */
363
+ function each_limit(
364
+ $iterable,
365
+ $concurrency,
366
+ callable $onFulfilled = null,
367
+ callable $onRejected = null
368
+ ) {
369
+ return (new EachPromise($iterable, [
370
+ 'fulfilled' => $onFulfilled,
371
+ 'rejected' => $onRejected,
372
+ 'concurrency' => $concurrency
373
+ ]))->promise();
374
+ }
375
+
376
+ /**
377
+ * Like each_limit, but ensures that no promise in the given $iterable argument
378
+ * is rejected. If any promise is rejected, then the aggregate promise is
379
+ * rejected with the encountered rejection.
380
+ *
381
+ * @param mixed $iterable
382
+ * @param int|callable $concurrency
383
+ * @param callable $onFulfilled
384
+ *
385
+ * @return mixed
386
+ */
387
+ function each_limit_all(
388
+ $iterable,
389
+ $concurrency,
390
+ callable $onFulfilled = null
391
+ ) {
392
+ return each_limit(
393
+ $iterable,
394
+ $concurrency,
395
+ $onFulfilled,
396
+ function ($reason, $idx, PromiseInterface $aggregate) {
397
+ $aggregate->reject($reason);
398
+ }
399
+ );
400
+ }
401
+
402
+ /**
403
+ * Returns true if a promise is fulfilled.
404
+ *
405
+ * @param PromiseInterface $promise
406
+ *
407
+ * @return bool
408
+ */
409
+ function is_fulfilled(PromiseInterface $promise)
410
+ {
411
+ return $promise->getState() === PromiseInterface::FULFILLED;
412
+ }
413
+
414
+ /**
415
+ * Returns true if a promise is rejected.
416
+ *
417
+ * @param PromiseInterface $promise
418
+ *
419
+ * @return bool
420
+ */
421
+ function is_rejected(PromiseInterface $promise)
422
+ {
423
+ return $promise->getState() === PromiseInterface::REJECTED;
424
+ }
425
+
426
+ /**
427
+ * Returns true if a promise is fulfilled or rejected.
428
+ *
429
+ * @param PromiseInterface $promise
430
+ *
431
+ * @return bool
432
+ */
433
+ function is_settled(PromiseInterface $promise)
434
+ {
435
+ return $promise->getState() !== PromiseInterface::PENDING;
436
+ }
437
+
438
+ /**
439
+ * Creates a promise that is resolved using a generator that yields values or
440
+ * promises (somewhat similar to C#'s async keyword).
441
+ *
442
+ * When called, the coroutine function will start an instance of the generator
443
+ * and returns a promise that is fulfilled with its final yielded value.
444
+ *
445
+ * Control is returned back to the generator when the yielded promise settles.
446
+ * This can lead to less verbose code when doing lots of sequential async calls
447
+ * with minimal processing in between.
448
+ *
449
+ * use GuzzleHttp\Promise;
450
+ *
451
+ * function createPromise($value) {
452
+ * return new Promise\FulfilledPromise($value);
453
+ * }
454
+ *
455
+ * $promise = Promise\coroutine(function () {
456
+ * $value = (yield createPromise('a'));
457
+ * try {
458
+ * $value = (yield createPromise($value . 'b'));
459
+ * } catch (\Exception $e) {
460
+ * // The promise was rejected.
461
+ * }
462
+ * yield $value . 'c';
463
+ * });
464
+ *
465
+ * // Outputs "abc"
466
+ * $promise->then(function ($v) { echo $v; });
467
+ *
468
+ * @param callable $generatorFn Generator function to wrap into a promise.
469
+ *
470
+ * @return Promise
471
+ * @link https://github.com/petkaantonov/bluebird/blob/master/API.md#generators inspiration
472
+ */
473
+ function coroutine(callable $generatorFn)
474
+ {
475
+ $generator = $generatorFn();
476
+ return __next_coroutine($generator->current(), $generator)->then();
477
+ }
478
+
479
+ /** @internal */
480
+ function __next_coroutine($yielded, \Generator $generator)
481
+ {
482
+ return promise_for($yielded)->then(
483
+ function ($value) use ($generator) {
484
+ $nextYield = $generator->send($value);
485
+ return $generator->valid()
486
+ ? __next_coroutine($nextYield, $generator)
487
+ : $value;
488
+ },
489
+ function ($reason) use ($generator) {
490
+ $nextYield = $generator->throw(exception_for($reason));
491
+ // The throw was caught, so keep iterating on the coroutine
492
+ return __next_coroutine($nextYield, $generator);
493
+ }
494
+ );
495
+ }
app/api/Ctct/vendor/guzzlehttp/promises/src/functions_include.php ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // Don't redefine the functions if included multiple times.
4
+ if (!function_exists('GuzzleHttp\Promise\promise_for')) {
5
+ require __DIR__ . '/functions.php';
6
+ }
app/api/Ctct/vendor/guzzlehttp/promises/tests/AggregateExceptionTest.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Promise\Tests;
3
+
4
+ use GuzzleHttp\Promise\AggregateException;
5
+
6
+ class AggregateExceptionTest extends \PHPUnit_Framework_TestCase
7
+ {
8
+ public function testHasReason()
9
+ {
10
+ $e = new AggregateException('foo', ['baz', 'bar']);
11
+ $this->assertContains('foo', $e->getMessage());
12
+ $this->assertEquals(['baz', 'bar'], $e->getReason());
13
+ }
14
+ }
app/api/Ctct/vendor/guzzlehttp/promises/tests/EachPromiseTest.php ADDED
@@ -0,0 +1,294 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Promise\Tests;
3
+
4
+ use GuzzleHttp\Promise\RejectedPromise;
5
+ use GuzzleHttp\Promise\FulfilledPromise;
6
+ use GuzzleHttp\Promise\Promise;
7
+ use GuzzleHttp\Promise\PromiseInterface;
8
+ use GuzzleHttp\Promise\EachPromise;
9
+ use GuzzleHttp\Promise as P;
10
+
11
+ /**
12
+ * @covers GuzzleHttp\Promise\EachPromise
13
+ */
14
+ class EachPromiseTest extends \PHPUnit_Framework_TestCase
15
+ {
16
+ public function testReturnsSameInstance()
17
+ {
18
+ $each = new EachPromise([], ['concurrency' => 100]);
19
+ $this->assertSame($each->promise(), $each->promise());
20
+ }
21
+
22
+ public function testInvokesAllPromises()
23
+ {
24
+ $promises = [new Promise(), new Promise(), new Promise()];
25
+ $called = [];
26
+ $each = new EachPromise($promises, [
27
+ 'fulfilled' => function ($value) use (&$called) {
28
+ $called[] = $value;
29
+ }
30
+ ]);
31
+ $p = $each->promise();
32
+ $promises[0]->resolve('a');
33
+ $promises[1]->resolve('c');
34
+ $promises[2]->resolve('b');
35
+ P\queue()->run();
36
+ $this->assertEquals(['a', 'c', 'b'], $called);
37
+ $this->assertEquals(PromiseInterface::FULFILLED, $p->getState());
38
+ }
39
+
40
+ public function testIsWaitable()
41
+ {
42
+ $a = new Promise(function () use (&$a) { $a->resolve('a'); });
43
+ $b = new Promise(function () use (&$b) { $b->resolve('b'); });
44
+ $called = [];
45
+ $each = new EachPromise([$a, $b], [
46
+ 'fulfilled' => function ($value) use (&$called) { $called[] = $value; }
47
+ ]);
48
+ $p = $each->promise();
49
+ $this->assertNull($p->wait());
50
+ $this->assertEquals(PromiseInterface::FULFILLED, $p->getState());
51
+ $this->assertEquals(['a', 'b'], $called);
52
+ }
53
+
54
+ public function testCanResolveBeforeConsumingAll()
55
+ {
56
+ $called = 0;
57
+ $a = new Promise(function () use (&$a) { $a->resolve('a'); });
58
+ $b = new Promise(function () { $this->fail(); });
59
+ $each = new EachPromise([$a, $b], [
60
+ 'fulfilled' => function ($value, $idx, Promise $aggregate) use (&$called) {
61
+ $this->assertSame($idx, 0);
62
+ $this->assertEquals('a', $value);
63
+ $aggregate->resolve(null);
64
+ $called++;
65
+ },
66
+ 'rejected' => function (\Exception $reason) {
67
+ $this->fail($reason->getMessage());
68
+ }
69
+ ]);
70
+ $p = $each->promise();
71
+ $p->wait();
72
+ $this->assertNull($p->wait());
73
+ $this->assertEquals(1, $called);
74
+ $this->assertEquals(PromiseInterface::FULFILLED, $a->getState());
75
+ $this->assertEquals(PromiseInterface::PENDING, $b->getState());
76
+ // Resolving $b has no effect on the aggregate promise.
77
+ $b->resolve('foo');
78
+ $this->assertEquals(1, $called);
79
+ }
80
+
81
+ public function testLimitsPendingPromises()
82
+ {
83
+ $pending = [new Promise(), new Promise(), new Promise(), new Promise()];
84
+ $promises = new \ArrayIterator($pending);
85
+ $each = new EachPromise($promises, ['concurrency' => 2]);
86
+ $p = $each->promise();
87
+ $this->assertCount(2, $this->readAttribute($each, 'pending'));
88
+ $pending[0]->resolve('a');
89
+ $this->assertCount(2, $this->readAttribute($each, 'pending'));
90
+ $this->assertTrue($promises->valid());
91
+ $pending[1]->resolve('b');
92
+ P\queue()->run();
93
+ $this->assertCount(2, $this->readAttribute($each, 'pending'));
94
+ $this->assertTrue($promises->valid());
95
+ $promises[2]->resolve('c');
96
+ P\queue()->run();
97
+ $this->assertCount(1, $this->readAttribute($each, 'pending'));
98
+ $this->assertEquals(PromiseInterface::PENDING, $p->getState());
99
+ $promises[3]->resolve('d');
100
+ P\queue()->run();
101
+ $this->assertNull($this->readAttribute($each, 'pending'));
102
+ $this->assertEquals(PromiseInterface::FULFILLED, $p->getState());
103
+ $this->assertFalse($promises->valid());
104
+ }
105
+
106
+ public function testDynamicallyLimitsPendingPromises()
107
+ {
108
+ $calls = [];
109
+ $pendingFn = function ($count) use (&$calls) {
110
+ $calls[] = $count;
111
+ return 2;
112
+ };
113
+ $pending = [new Promise(), new Promise(), new Promise(), new Promise()];
114
+ $promises = new \ArrayIterator($pending);
115
+ $each = new EachPromise($promises, ['concurrency' => $pendingFn]);
116
+ $p = $each->promise();
117
+ $this->assertCount(2, $this->readAttribute($each, 'pending'));
118
+ $pending[0]->resolve('a');
119
+ $this->assertCount(2, $this->readAttribute($each, 'pending'));
120
+ $this->assertTrue($promises->valid());
121
+ $pending[1]->resolve('b');
122
+ $this->assertCount(2, $this->readAttribute($each, 'pending'));
123
+ P\queue()->run();
124
+ $this->assertTrue($promises->valid());
125
+ $promises[2]->resolve('c');
126
+ P\queue()->run();
127
+ $this->assertCount(1, $this->readAttribute($each, 'pending'));
128
+ $this->assertEquals(PromiseInterface::PENDING, $p->getState());
129
+ $promises[3]->resolve('d');
130
+ P\queue()->run();
131
+ $this->assertNull($this->readAttribute($each, 'pending'));
132
+ $this->assertEquals(PromiseInterface::FULFILLED, $p->getState());
133
+ $this->assertEquals([0, 1, 1, 1], $calls);
134
+ $this->assertFalse($promises->valid());
135
+ }
136
+
137
+ public function testClearsReferencesWhenResolved()
138
+ {
139
+ $called = false;
140
+ $a = new Promise(function () use (&$a, &$called) {
141
+ $a->resolve('a');
142
+ $called = true;
143
+ });
144
+ $each = new EachPromise([$a], [
145
+ 'concurrency' => function () { return 1; },
146
+ 'fulfilled' => function () {},
147
+ 'rejected' => function () {}
148
+ ]);
149
+ $each->promise()->wait();
150
+ $this->assertNull($this->readAttribute($each, 'onFulfilled'));
151
+ $this->assertNull($this->readAttribute($each, 'onRejected'));
152
+ $this->assertNull($this->readAttribute($each, 'iterable'));
153
+ $this->assertNull($this->readAttribute($each, 'pending'));
154
+ $this->assertNull($this->readAttribute($each, 'concurrency'));
155
+ $this->assertTrue($called);
156
+ }
157
+
158
+ public function testCanBeCancelled()
159
+ {
160
+ $this->markTestIncomplete();
161
+ }
162
+
163
+ public function testFulfillsImmediatelyWhenGivenAnEmptyIterator()
164
+ {
165
+ $each = new EachPromise(new \ArrayIterator([]));
166
+ $result = $each->promise()->wait();
167
+ }
168
+
169
+ public function testDoesNotBlowStackWithFulfilledPromises()
170
+ {
171
+ $pending = [];
172
+ for ($i = 0; $i < 100; $i++) {
173
+ $pending[] = new FulfilledPromise($i);
174
+ }
175
+ $values = [];
176
+ $each = new EachPromise($pending, [
177
+ 'fulfilled' => function ($value) use (&$values) {
178
+ $values[] = $value;
179
+ }
180
+ ]);
181
+ $called = false;
182
+ $each->promise()->then(function () use (&$called) {
183
+ $called = true;
184
+ });
185
+ $this->assertFalse($called);
186
+ P\queue()->run();
187
+ $this->assertTrue($called);
188
+ $this->assertEquals(range(0, 99), $values);
189
+ }
190
+
191
+ public function testDoesNotBlowStackWithRejectedPromises()
192
+ {
193
+ $pending = [];
194
+ for ($i = 0; $i < 100; $i++) {
195
+ $pending[] = new RejectedPromise($i);
196
+ }
197
+ $values = [];
198
+ $each = new EachPromise($pending, [
199
+ 'rejected' => function ($value) use (&$values) {
200
+ $values[] = $value;
201
+ }
202
+ ]);
203
+ $called = false;
204
+ $each->promise()->then(
205
+ function () use (&$called) { $called = true; },
206
+ function () { $this->fail('Should not have rejected.'); }
207
+ );
208
+ $this->assertFalse($called);
209
+ P\queue()->run();
210
+ $this->assertTrue($called);
211
+ $this->assertEquals(range(0, 99), $values);
212
+ }
213
+
214
+ public function testReturnsPromiseForWhatever()
215
+ {
216
+ $called = [];
217
+ $arr = ['a', 'b'];
218
+ $each = new EachPromise($arr, [
219
+ 'fulfilled' => function ($v) use (&$called) { $called[] = $v; }
220
+ ]);
221
+ $p = $each->promise();
222
+ $this->assertNull($p->wait());
223
+ $this->assertEquals(['a', 'b'], $called);
224
+ }
225
+
226
+ public function testRejectsAggregateWhenNextThrows()
227
+ {
228
+ $iter = function () {
229
+ yield 'a';
230
+ throw new \Exception('Failure');
231
+ };
232
+ $each = new EachPromise($iter());
233
+ $p = $each->promise();
234
+ $e = null;
235
+ $received = null;
236
+ $p->then(null, function ($reason) use (&$e) { $e = $reason; });
237
+ P\queue()->run();
238
+ $this->assertInstanceOf('Exception', $e);
239
+ $this->assertEquals('Failure', $e->getMessage());
240
+ }
241
+
242
+ public function testDoesNotCallNextOnIteratorUntilNeededWhenWaiting()
243
+ {
244
+ $results = [];
245
+ $values = [10];
246
+ $remaining = 9;
247
+ $iter = function () use (&$values) {
248
+ while ($value = array_pop($values)) {
249
+ yield $value;
250
+ }
251
+ };
252
+ $each = new EachPromise($iter(), [
253
+ 'concurrency' => 1,
254
+ 'fulfilled' => function ($r) use (&$results, &$values, &$remaining) {
255
+ $results[] = $r;
256
+ if ($remaining > 0) {
257
+ $values[] = $remaining--;
258
+ }
259
+ }
260
+ ]);
261
+ $each->promise()->wait();
262
+ $this->assertEquals(range(10, 1), $results);
263
+ }
264
+
265
+ public function testDoesNotCallNextOnIteratorUntilNeededWhenAsync()
266
+ {
267
+ $firstPromise = new Promise();
268
+ $pending = [$firstPromise];
269
+ $values = [$firstPromise];
270
+ $results = [];
271
+ $remaining = 9;
272
+ $iter = function () use (&$values) {
273
+ while ($value = array_pop($values)) {
274
+ yield $value;
275
+ }
276
+ };
277
+ $each = new EachPromise($iter(), [
278
+ 'concurrency' => 1,
279
+ 'fulfilled' => function ($r) use (&$results, &$values, &$remaining, &$pending) {
280
+ $results[] = $r;
281
+ if ($remaining-- > 0) {
282
+ $pending[] = $values[] = new Promise();
283
+ }
284
+ }
285
+ ]);
286
+ $i = 0;
287
+ $each->promise();
288
+ while ($promise = array_pop($pending)) {
289
+ $promise->resolve($i++);
290
+ P\queue()->run();
291
+ }
292
+ $this->assertEquals(range(0, 9), $results);
293
+ }
294
+ }
app/api/Ctct/vendor/guzzlehttp/promises/tests/FulfilledPromiseTest.php ADDED
@@ -0,0 +1,108 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Tests\Promise;
3
+
4
+ use GuzzleHttp\Promise\Promise;
5
+ use GuzzleHttp\Promise\FulfilledPromise;
6
+
7
+ /**
8
+ * @covers GuzzleHttp\Promise\FulfilledPromise
9
+ */
10
+ class FulfilledPromiseTest extends \PHPUnit_Framework_TestCase
11
+ {
12
+ public function testReturnsValueWhenWaitedUpon()
13
+ {
14
+ $p = new FulfilledPromise('foo');
15
+ $this->assertEquals('fulfilled', $p->getState());
16
+ $this->assertEquals('foo', $p->wait(true));
17
+ }
18
+
19
+ public function testCannotCancel()
20
+ {
21
+ $p = new FulfilledPromise('foo');
22
+ $this->assertEquals('fulfilled', $p->getState());
23
+ $p->cancel();
24
+ $this->assertEquals('foo', $p->wait());
25
+ }
26
+
27
+ /**
28
+ * @expectedException \LogicException
29
+ * @exepctedExceptionMessage Cannot resolve a fulfilled promise
30
+ */
31
+ public function testCannotResolve()
32
+ {
33
+ $p = new FulfilledPromise('foo');
34
+ $p->resolve('bar');
35
+ }
36
+
37
+ /**
38
+ * @expectedException \LogicException
39
+ * @exepctedExceptionMessage Cannot reject a fulfilled promise
40
+ */
41
+ public function testCannotReject()
42
+ {
43
+ $p = new FulfilledPromise('foo');
44
+ $p->reject('bar');
45
+ }
46
+
47
+ public function testCanResolveWithSameValue()
48
+ {
49
+ $p = new FulfilledPromise('foo');
50
+ $p->resolve('foo');
51
+ }
52
+
53
+ /**
54
+ * @expectedException \InvalidArgumentException
55
+ */
56
+ public function testCannotResolveWithPromise()
57
+ {
58
+ new FulfilledPromise(new Promise());
59
+ }
60
+
61
+ public function testReturnsSelfWhenNoOnFulfilled()
62
+ {
63
+ $p = new FulfilledPromise('a');
64
+ $this->assertSame($p, $p->then());
65
+ }
66
+
67
+ public function testAsynchronouslyInvokesOnFulfilled()
68
+ {
69
+ $p = new FulfilledPromise('a');
70
+ $r = null;
71
+ $f = function ($d) use (&$r) { $r = $d; };
72
+ $p2 = $p->then($f);
73
+ $this->assertNotSame($p, $p2);
74
+ $this->assertNull($r);
75
+ \GuzzleHttp\Promise\queue()->run();
76
+ $this->assertEquals('a', $r);
77
+ }
78
+
79
+ public function testReturnsNewRejectedWhenOnFulfilledFails()
80
+ {
81
+ $p = new FulfilledPromise('a');
82
+ $f = function () { throw new \Exception('b'); };
83
+ $p2 = $p->then($f);
84
+ $this->assertNotSame($p, $p2);
85
+ try {
86
+ $p2->wait();
87
+ $this->fail();
88
+ } catch (\Exception $e) {
89
+ $this->assertEquals('b', $e->getMessage());
90
+ }
91
+ }
92
+
93
+ public function testOtherwiseIsSugarForRejections()
94
+ {
95
+ $c = null;
96
+ $p = new FulfilledPromise('foo');
97
+ $p->otherwise(function ($v) use (&$c) { $c = $v; });
98
+ $this->assertNull($c);
99
+ }
100
+
101
+ public function testDoesNotTryToFulfillTwiceDuringTrampoline()
102
+ {
103
+ $fp = new FulfilledPromise('a');
104
+ $t1 = $fp->then(function ($v) { return $v . ' b'; });
105
+ $t1->resolve('why!');
106
+ $this->assertEquals('why!', $t1->wait());
107
+ }
108
+ }
app/api/Ctct/vendor/guzzlehttp/promises/tests/NotPromiseInstance.php ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Promise\Tests;
3
+
4
+ use GuzzleHttp\Promise\Promise;
5
+ use GuzzleHttp\Promise\PromiseInterface;
6
+
7
+ class NotPromiseInstance extends Thennable implements PromiseInterface
8
+ {
9
+ private $nextPromise = null;
10
+
11
+ public function __construct()
12
+ {
13
+ $this->nextPromise = new Promise();
14
+ }
15
+
16
+ public function then(callable $res = null, callable $rej = null)
17
+ {
18
+ return $this->nextPromise->then($res, $rej);
19
+ }
20
+
21
+ public function otherwise(callable $onRejected)
22
+ {
23
+ return $this->then($onRejected);
24
+ }
25
+
26
+ public function resolve($value)
27
+ {
28
+ $this->nextPromise->resolve($value);
29
+ }
30
+
31
+ public function reject($reason)
32
+ {
33
+ $this->nextPromise->reject($reason);
34
+ }
35
+
36
+ public function wait($unwrap = true, $defaultResolution = null)
37
+ {
38
+
39
+ }
40
+
41
+ public function cancel()
42
+ {
43
+
44
+ }
45
+
46
+ public function getState()
47
+ {
48
+ return $this->nextPromise->getState();
49
+ }
50
+ }
app/api/Ctct/vendor/guzzlehttp/promises/tests/PromiseTest.php ADDED
@@ -0,0 +1,579 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Promise\Tests;
3
+
4
+ use GuzzleHttp\Promise\CancellationException;
5
+ use GuzzleHttp\Promise as P;
6
+ use GuzzleHttp\Promise\Promise;
7
+ use GuzzleHttp\Promise\RejectedPromise;
8
+ use GuzzleHttp\Promise\RejectionException;
9
+
10
+ /**
11
+ * @covers GuzzleHttp\Promise\Promise
12
+ */
13
+ class PromiseTest extends \PHPUnit_Framework_TestCase
14
+ {
15
+ /**
16
+ * @expectedException \LogicException
17
+ * @expectedExceptionMessage The promise is already fulfilled
18
+ */
19
+ public function testCannotResolveNonPendingPromise()
20
+ {
21
+ $p = new Promise();
22
+ $p->resolve('foo');
23
+ $p->resolve('bar');
24
+ $this->assertEquals('foo', $p->wait());
25
+ }
26
+
27
+ public function testCanResolveWithSameValue()
28
+ {
29
+ $p = new Promise();
30
+ $p->resolve('foo');
31
+ $p->resolve('foo');
32
+ }
33
+
34
+ /**
35
+ * @expectedException \LogicException
36
+ * @expectedExceptionMessage Cannot change a fulfilled promise to rejected
37
+ */
38
+ public function testCannotRejectNonPendingPromise()
39
+ {
40
+ $p = new Promise();
41
+ $p->resolve('foo');
42
+ $p->reject('bar');
43
+ $this->assertEquals('foo', $p->wait());
44
+ }
45
+
46
+ public function testCanRejectWithSameValue()
47
+ {
48
+ $p = new Promise();
49
+ $p->reject('foo');
50
+ $p->reject('foo');
51
+ }
52
+
53
+ /**
54
+ * @expectedException \LogicException
55
+ * @expectedExceptionMessage Cannot change a fulfilled promise to rejected
56
+ */
57
+ public function testCannotRejectResolveWithSameValue()
58
+ {
59
+ $p = new Promise();
60
+ $p->resolve('foo');
61
+ $p->reject('foo');
62
+ }
63
+
64
+ public function testInvokesWaitFunction()
65
+ {
66
+ $p = new Promise(function () use (&$p) { $p->resolve('10'); });
67
+ $this->assertEquals('10', $p->wait());
68
+ }
69
+
70
+ /**
71
+ * @expectedException \GuzzleHttp\Promise\RejectionException
72
+ */
73
+ public function testRejectsAndThrowsWhenWaitFailsToResolve()
74
+ {
75
+ $p = new Promise(function () {});
76
+ $p->wait();
77
+ }
78
+
79
+ /**
80
+ * @expectedException \GuzzleHttp\Promise\RejectionException
81
+ * @expectedExceptionMessage The promise was rejected with reason: foo
82
+ */
83
+ public function testThrowsWhenUnwrapIsRejectedWithNonException()
84
+ {
85
+ $p = new Promise(function () use (&$p) { $p->reject('foo'); });
86
+ $p->wait();
87
+ }
88
+
89
+ /**
90
+ * @expectedException \UnexpectedValueException
91
+ * @expectedExceptionMessage foo
92
+ */
93
+ public function testThrowsWhenUnwrapIsRejectedWithException()
94
+ {
95
+ $e = new \UnexpectedValueException('foo');
96
+ $p = new Promise(function () use (&$p, $e) { $p->reject($e); });
97
+ $p->wait();
98
+ }
99
+
100
+ public function testDoesNotUnwrapExceptionsWhenDisabled()
101
+ {
102
+ $p = new Promise(function () use (&$p) { $p->reject('foo'); });
103
+ $this->assertEquals('pending', $p->getState());
104
+ $p->wait(false);
105
+ $this->assertEquals('rejected', $p->getState());
106
+ }
107
+
108
+ public function testRejectsSelfWhenWaitThrows()
109
+ {
110
+ $e = new \UnexpectedValueException('foo');
111
+ $p = new Promise(function () use ($e) { throw $e; });
112
+ try {
113
+ $p->wait();
114
+ $this->fail();
115
+ } catch (\UnexpectedValueException $e) {
116
+ $this->assertEquals('rejected', $p->getState());
117
+ }
118
+ }
119
+
120
+ public function testWaitsOnNestedPromises()
121
+ {
122
+ $p = new Promise(function () use (&$p) { $p->resolve('_'); });
123
+ $p2 = new Promise(function () use (&$p2) { $p2->resolve('foo'); });
124
+ $p3 = $p->then(function () use ($p2) { return $p2; });
125
+ $this->assertSame('foo', $p3->wait());
126
+ }
127
+
128
+ /**
129
+ * @expectedException \GuzzleHttp\Promise\RejectionException
130
+ */
131
+ public function testThrowsWhenWaitingOnPromiseWithNoWaitFunction()
132
+ {
133
+ $p = new Promise();
134
+ $p->wait();
135
+ }
136
+
137
+ public function testThrowsWaitExceptionAfterPromiseIsResolved()
138
+ {
139
+ $p = new Promise(function () use (&$p) {
140
+ $p->reject('Foo!');
141
+ throw new \Exception('Bar?');
142
+ });
143
+
144
+ try {
145
+ $p->wait();
146
+ $this->fail();
147
+ } catch (\Exception $e) {
148
+ $this->assertEquals('Bar?', $e->getMessage());
149
+ }
150
+ }
151
+
152
+ public function testGetsActualWaitValueFromThen()
153
+ {
154
+ $p = new Promise(function () use (&$p) { $p->reject('Foo!'); });
155
+ $p2 = $p->then(null, function ($reason) {
156
+ return new RejectedPromise([$reason]);
157
+ });
158
+
159
+ try {
160
+ $p2->wait();
161
+ $this->fail('Should have thrown');
162
+ } catch (RejectionException $e) {
163
+ $this->assertEquals(['Foo!'], $e->getReason());
164
+ }
165
+ }
166
+
167
+ public function testWaitBehaviorIsBasedOnLastPromiseInChain()
168
+ {
169
+ $p3 = new Promise(function () use (&$p3) { $p3->resolve('Whoop'); });
170
+ $p2 = new Promise(function () use (&$p2, $p3) { $p2->reject($p3); });
171
+ $p = new Promise(function () use (&$p, $p2) { $p->reject($p2); });
172
+ $this->assertEquals('Whoop', $p->wait());
173
+ }
174
+
175
+ public function testCannotCancelNonPending()
176
+ {
177
+ $p = new Promise();
178
+ $p->resolve('foo');
179
+ $p->cancel();
180
+ $this->assertEquals('fulfilled', $p->getState());
181
+ }
182
+
183
+ /**
184
+ * @expectedException \GuzzleHttp\Promise\CancellationException
185
+ */
186
+ public function testCancelsPromiseWhenNoCancelFunction()
187
+ {
188
+ $p = new Promise();
189
+ $p->cancel();
190
+ $this->assertEquals('rejected', $p->getState());
191
+ $p->wait();
192
+ }
193
+
194
+ public function testCancelsPromiseWithCancelFunction()
195
+ {
196
+ $called = false;
197
+ $p = new Promise(null, function () use (&$called) { $called = true; });
198
+ $p->cancel();
199
+ $this->assertEquals('rejected', $p->getState());
200
+ $this->assertTrue($called);
201
+ }
202
+
203
+ public function testCancelsUppermostPendingPromise()
204
+ {
205
+ $called = false;
206
+ $p1 = new Promise(null, function () use (&$called) { $called = true; });
207
+ $p2 = $p1->then(function () {});
208
+ $p3 = $p2->then(function () {});
209
+ $p4 = $p3->then(function () {});
210
+ $p3->cancel();
211
+ $this->assertEquals('rejected', $p1->getState());
212
+ $this->assertEquals('rejected', $p2->getState());
213
+ $this->assertEquals('rejected', $p3->getState());
214
+ $this->assertEquals('pending', $p4->getState());
215
+ $this->assertTrue($called);
216
+
217
+ try {
218
+ $p3->wait();
219
+ $this->fail();
220
+ } catch (CancellationException $e) {
221
+ $this->assertContains('cancelled', $e->getMessage());
222
+ }
223
+
224
+ try {
225
+ $p4->wait();
226
+ $this->fail();
227
+ } catch (CancellationException $e) {
228
+ $this->assertContains('cancelled', $e->getMessage());
229
+ }
230
+
231
+ $this->assertEquals('rejected', $p4->getState());
232
+ }
233
+
234
+ public function testCancelsChildPromises()
235
+ {
236
+ $called1 = $called2 = $called3 = false;
237
+ $p1 = new Promise(null, function () use (&$called1) { $called1 = true; });
238
+ $p2 = new Promise(null, function () use (&$called2) { $called2 = true; });
239
+ $p3 = new Promise(null, function () use (&$called3) { $called3 = true; });
240
+ $p4 = $p2->then(function () use ($p3) { return $p3; });
241
+ $p5 = $p4->then(function () { $this->fail(); });
242
+ $p4->cancel();
243
+ $this->assertEquals('pending', $p1->getState());
244
+ $this->assertEquals('rejected', $p2->getState());
245
+ $this->assertEquals('rejected', $p4->getState());
246
+ $this->assertEquals('pending', $p5->getState());
247
+ $this->assertFalse($called1);
248
+ $this->assertTrue($called2);
249
+ $this->assertFalse($called3);
250
+ }
251
+
252
+ public function testRejectsPromiseWhenCancelFails()
253
+ {
254
+ $called = false;
255
+ $p = new Promise(null, function () use (&$called) {
256
+ $called = true;
257
+ throw new \Exception('e');
258
+ });
259
+ $p->cancel();
260
+ $this->assertEquals('rejected', $p->getState());
261
+ $this->assertTrue($called);
262
+ try {
263
+ $p->wait();
264
+ $this->fail();
265
+ } catch (\Exception $e) {
266
+ $this->assertEquals('e', $e->getMessage());
267
+ }
268
+ }
269
+
270
+ public function testCreatesPromiseWhenFulfilledAfterThen()
271
+ {
272
+ $p = new Promise();
273
+ $carry = null;
274
+ $p2 = $p->then(function ($v) use (&$carry) { $carry = $v; });
275
+ $this->assertNotSame($p, $p2);
276
+ $p->resolve('foo');
277
+ P\queue()->run();
278
+
279
+ $this->assertEquals('foo', $carry);
280
+ }
281
+
282
+ public function testCreatesPromiseWhenFulfilledBeforeThen()
283
+ {
284
+ $p = new Promise();
285
+ $p->resolve('foo');
286
+ $carry = null;
287
+ $p2 = $p->then(function ($v) use (&$carry) { $carry = $v; });
288
+ $this->assertNotSame($p, $p2);
289
+ $this->assertNull($carry);
290
+ \GuzzleHttp\Promise\queue()->run();
291
+ $this->assertEquals('foo', $carry);
292
+ }
293
+
294
+ public function testCreatesPromiseWhenFulfilledWithNoCallback()
295
+ {
296
+ $p = new Promise();
297
+ $p->resolve('foo');
298
+ $p2 = $p->then();
299
+ $this->assertNotSame($p, $p2);
300
+ $this->assertInstanceOf('GuzzleHttp\Promise\FulfilledPromise', $p2);
301
+ }
302
+
303
+ public function testCreatesPromiseWhenRejectedAfterThen()
304
+ {
305
+ $p = new Promise();
306
+ $carry = null;
307
+ $p2 = $p->then(null, function ($v) use (&$carry) { $carry = $v; });
308
+ $this->assertNotSame($p, $p2);
309
+ $p->reject('foo');
310
+ P\queue()->run();
311
+ $this->assertEquals('foo', $carry);
312
+ }
313
+
314
+ public function testCreatesPromiseWhenRejectedBeforeThen()
315
+ {
316
+ $p = new Promise();
317
+ $p->reject('foo');
318
+ $carry = null;
319
+ $p2 = $p->then(null, function ($v) use (&$carry) { $carry = $v; });
320
+ $this->assertNotSame($p, $p2);
321
+ $this->assertNull($carry);
322
+ P\queue()->run();
323
+ $this->assertEquals('foo', $carry);
324
+ }
325
+
326
+ public function testCreatesPromiseWhenRejectedWithNoCallback()
327
+ {
328
+ $p = new Promise();
329
+ $p->reject('foo');
330
+ $p2 = $p->then();
331
+ $this->assertNotSame($p, $p2);
332
+ $this->assertInstanceOf('GuzzleHttp\Promise\RejectedPromise', $p2);
333
+ }
334
+
335
+ public function testInvokesWaitFnsForThens()
336
+ {
337
+ $p = new Promise(function () use (&$p) { $p->resolve('a'); });
338
+ $p2 = $p
339
+ ->then(function ($v) { return $v . '-1-'; })
340
+ ->then(function ($v) { return $v . '2'; });
341
+ $this->assertEquals('a-1-2', $p2->wait());
342
+ }
343
+
344
+ public function testStacksThenWaitFunctions()
345
+ {
346
+ $p1 = new Promise(function () use (&$p1) { $p1->resolve('a'); });
347
+ $p2 = new Promise(function () use (&$p2) { $p2->resolve('b'); });
348
+ $p3 = new Promise(function () use (&$p3) { $p3->resolve('c'); });
349
+ $p4 = $p1
350
+ ->then(function () use ($p2) { return $p2; })
351
+ ->then(function () use ($p3) { return $p3; });
352
+ $this->assertEquals('c', $p4->wait());
353
+ }
354
+
355
+ public function testForwardsFulfilledDownChainBetweenGaps()
356
+ {
357
+ $p = new Promise();
358
+ $r = $r2 = null;
359
+ $p->then(null, null)
360
+ ->then(function ($v) use (&$r) { $r = $v; return $v . '2'; })
361
+ ->then(function ($v) use (&$r2) { $r2 = $v; });
362
+ $p->resolve('foo');
363
+ P\queue()->run();
364
+ $this->assertEquals('foo', $r);
365
+ $this->assertEquals('foo2', $r2);
366
+ }
367
+
368
+ public function testForwardsRejectedPromisesDownChainBetweenGaps()
369
+ {
370
+ $p = new Promise();
371
+ $r = $r2 = null;
372
+ $p->then(null, null)
373
+ ->then(null, function ($v) use (&$r) { $r = $v; return $v . '2'; })
374
+ ->then(function ($v) use (&$r2) { $r2 = $v; });
375
+ $p->reject('foo');
376
+ P\queue()->run();
377
+ $this->assertEquals('foo', $r);
378
+ $this->assertEquals('foo2', $r2);
379
+ }
380
+
381
+ public function testForwardsThrownPromisesDownChainBetweenGaps()
382
+ {
383
+ $e = new \Exception();
384
+ $p = new Promise();
385
+ $r = $r2 = null;
386
+ $p->then(null, null)
387
+ ->then(null, function ($v) use (&$r, $e) {
388
+ $r = $v;
389
+ throw $e;
390
+ })
391
+ ->then(
392
+ null,
393
+ function ($v) use (&$r2) { $r2 = $v; }
394
+ );
395
+ $p->reject('foo');
396
+ P\queue()->run();
397
+ $this->assertEquals('foo', $r);
398
+ $this->assertSame($e, $r2);
399
+ }
400
+
401
+ public function testForwardsReturnedRejectedPromisesDownChainBetweenGaps()
402
+ {
403
+ $p = new Promise();
404
+ $rejected = new RejectedPromise('bar');
405
+ $r = $r2 = null;
406
+ $p->then(null, null)
407
+ ->then(null, function ($v) use (&$r, $rejected) {
408
+ $r = $v;
409
+ return $rejected;
410
+ })
411
+ ->then(
412
+ null,
413
+ function ($v) use (&$r2) { $r2 = $v; }
414
+ );
415
+ $p->reject('foo');
416
+ P\queue()->run();
417
+ $this->assertEquals('foo', $r);
418
+ $this->assertEquals('bar', $r2);
419
+ try {
420
+ $p->wait();
421
+ } catch (RejectionException $e) {
422
+ $this->assertEquals('foo', $e->getReason());
423
+ }
424
+ }
425
+
426
+ public function testForwardsHandlersToNextPromise()
427
+ {
428
+ $p = new Promise();
429
+ $p2 = new Promise();
430
+ $resolved = null;
431
+ $p
432
+ ->then(function ($v) use ($p2) { return $p2; })
433
+ ->then(function ($value) use (&$resolved) { $resolved = $value; });
434
+ $p->resolve('a');
435
+ $p2->resolve('b');
436
+ P\queue()->run();
437
+ $this->assertEquals('b', $resolved);
438
+ }
439
+
440
+ public function testRemovesReferenceFromChildWhenParentWaitedUpon()
441
+ {
442
+ $r = null;
443
+ $p = new Promise(function () use (&$p) { $p->resolve('a'); });
444
+ $p2 = new Promise(function () use (&$p2) { $p2->resolve('b'); });
445
+ $pb = $p->then(
446
+ function ($v) use ($p2, &$r) {
447
+ $r = $v;
448
+ return $p2;
449
+ })
450
+ ->then(function ($v) { return $v . '.'; });
451
+ $this->assertEquals('a', $p->wait());
452
+ $this->assertEquals('b', $p2->wait());
453
+ $this->assertEquals('b.', $pb->wait());
454
+ $this->assertEquals('a', $r);
455
+ }
456
+
457
+ public function testForwardsHandlersWhenFulfilledPromiseIsReturned()
458
+ {
459
+ $res = [];
460
+ $p = new Promise();
461
+ $p2 = new Promise();
462
+ $p2->resolve('foo');
463
+ $p2->then(function ($v) use (&$res) { $res[] = 'A:' . $v; });
464
+ // $res is A:foo
465
+ $p
466
+ ->then(function () use ($p2, &$res) { $res[] = 'B'; return $p2; })
467
+ ->then(function ($v) use (&$res) { $res[] = 'C:' . $v; });
468
+ $p->resolve('a');
469
+ $p->then(function ($v) use (&$res) { $res[] = 'D:' . $v; });
470
+ P\queue()->run();
471
+ $this->assertEquals(['A:foo', 'B', 'D:a', 'C:foo'], $res);
472
+ }
473
+
474
+ public function testForwardsHandlersWhenRejectedPromiseIsReturned()
475
+ {
476
+ $res = [];
477
+ $p = new Promise();
478
+ $p2 = new Promise();
479
+ $p2->reject('foo');
480
+ $p2->then(null, function ($v) use (&$res) { $res[] = 'A:' . $v; });
481
+ $p->then(null, function () use ($p2, &$res) { $res[] = 'B'; return $p2; })
482
+ ->then(null, function ($v) use (&$res) { $res[] = 'C:' . $v; });
483
+ $p->reject('a');
484
+ $p->then(null, function ($v) use (&$res) { $res[] = 'D:' . $v; });
485
+ P\queue()->run();
486
+ $this->assertEquals(['A:foo', 'B', 'D:a', 'C:foo'], $res);
487
+ }
488
+
489
+ public function testDoesNotForwardRejectedPromise()
490
+ {
491
+ $res = [];
492
+ $p = new Promise();
493
+ $p2 = new Promise();
494
+ $p2->cancel();
495
+ $p2->then(function ($v) use (&$res) { $res[] = "B:$v"; return $v; });
496
+ $p->then(function ($v) use ($p2, &$res) { $res[] = "B:$v"; return $p2; })
497
+ ->then(function ($v) use (&$res) { $res[] = 'C:' . $v; });
498
+ $p->resolve('a');
499
+ $p->then(function ($v) use (&$res) { $res[] = 'D:' . $v; });
500
+ P\queue()->run();
501
+ $this->assertEquals(['B:a', 'D:a'], $res);
502
+ }
503
+
504
+ public function testRecursivelyForwardsWhenOnlyThennable()
505
+ {
506
+ $res = [];
507
+ $p = new Promise();
508
+ $p2 = new Thennable();
509
+ $p2->resolve('foo');
510
+ $p2->then(function ($v) use (&$res) { $res[] = 'A:' . $v; });
511
+ $p->then(function () use ($p2, &$res) { $res[] = 'B'; return $p2; })
512
+ ->then(function ($v) use (&$res) { $res[] = 'C:' . $v; });
513
+ $p->resolve('a');
514
+ $p->then(function ($v) use (&$res) { $res[] = 'D:' . $v; });
515
+ P\queue()->run();
516
+ $this->assertEquals(['A:foo', 'B', 'D:a', 'C:foo'], $res);
517
+ }
518
+
519
+ public function testRecursivelyForwardsWhenNotInstanceOfPromise()
520
+ {
521
+ $res = [];
522
+ $p = new Promise();
523
+ $p2 = new NotPromiseInstance();
524
+ $p2->then(function ($v) use (&$res) { $res[] = 'A:' . $v; });
525
+ $p->then(function () use ($p2, &$res) { $res[] = 'B'; return $p2; })
526
+ ->then(function ($v) use (&$res) { $res[] = 'C:' . $v; });
527
+ $p->resolve('a');
528
+ $p->then(function ($v) use (&$res) { $res[] = 'D:' . $v; });
529
+ P\queue()->run();
530
+ $this->assertEquals(['B', 'D:a'], $res);
531
+ $p2->resolve('foo');
532
+ P\queue()->run();
533
+ $this->assertEquals(['B', 'D:a', 'A:foo', 'C:foo'], $res);
534
+ }
535
+
536
+ /**
537
+ * @expectedException \LogicException
538
+ * @expectedExceptionMessage Cannot fulfill or reject a promise with itself
539
+ */
540
+ public function testCannotResolveWithSelf()
541
+ {
542
+ $p = new Promise();
543
+ $p->resolve($p);
544
+ }
545
+
546
+ /**
547
+ * @expectedException \LogicException
548
+ * @expectedExceptionMessage Cannot fulfill or reject a promise with itself
549
+ */
550
+ public function testCannotRejectWithSelf()
551
+ {
552
+ $p = new Promise();
553
+ $p->reject($p);
554
+ }
555
+
556
+ public function testDoesNotBlowStackWhenWaitingOnNestedThens()
557
+ {
558
+ $inner = new Promise(function () use (&$inner) { $inner->resolve(0); });
559
+ $prev = $inner;
560
+ for ($i = 1; $i < 100; $i++) {
561
+ $prev = $prev->then(function ($i) { return $i + 1; });
562
+ }
563
+
564
+ $parent = new Promise(function () use (&$parent, $prev) {
565
+ $parent->resolve($prev);
566
+ });
567
+
568
+ $this->assertEquals(99, $parent->wait());
569
+ }
570
+
571
+ public function testOtherwiseIsSugarForRejections()
572
+ {
573
+ $p = new Promise();
574
+ $p->reject('foo');
575
+ $p->otherwise(function ($v) use (&$c) { $c = $v; });
576
+ P\queue()->run();
577
+ $this->assertEquals($c, 'foo');
578
+ }
579
+ }
app/api/Ctct/vendor/guzzlehttp/promises/tests/RejectedPromiseTest.php ADDED
@@ -0,0 +1,143 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Promise\Tests;
3
+
4
+ use GuzzleHttp\Promise\Promise;
5
+ use GuzzleHttp\Promise\RejectedPromise;
6
+
7
+ /**
8
+ * @covers GuzzleHttp\Promise\RejectedPromise
9
+ */
10
+ class RejectedPromiseTest extends \PHPUnit_Framework_TestCase
11
+ {
12
+ public function testThrowsReasonWhenWaitedUpon()
13
+ {
14
+ $p = new RejectedPromise('foo');
15
+ $this->assertEquals('rejected', $p->getState());
16
+ try {
17
+ $p->wait(true);
18
+ $this->fail();
19
+ } catch (\Exception $e) {
20
+ $this->assertEquals('rejected', $p->getState());
21
+ $this->assertContains('foo', $e->getMessage());
22
+ }
23
+ }
24
+
25
+ public function testCannotCancel()
26
+ {
27
+ $p = new RejectedPromise('foo');
28
+ $p->cancel();
29
+ $this->assertEquals('rejected', $p->getState());
30
+ }
31
+
32
+ /**
33
+ * @expectedException \LogicException
34
+ * @exepctedExceptionMessage Cannot resolve a rejected promise
35
+ */
36
+ public function testCannotResolve()
37
+ {
38
+ $p = new RejectedPromise('foo');
39
+ $p->resolve('bar');
40
+ }
41
+
42
+ /**
43
+ * @expectedException \LogicException
44
+ * @exepctedExceptionMessage Cannot reject a rejected promise
45
+ */
46
+ public function testCannotReject()
47
+ {
48
+ $p = new RejectedPromise('foo');
49
+ $p->reject('bar');
50
+ }
51
+
52
+ public function testCanRejectWithSameValue()
53
+ {
54
+ $p = new RejectedPromise('foo');
55
+ $p->reject('foo');
56
+ }
57
+
58
+ public function testThrowsSpecificException()
59
+ {
60
+ $e = new \Exception();
61
+ $p = new RejectedPromise($e);
62
+ try {
63
+ $p->wait(true);
64
+ $this->fail();
65
+ } catch (\Exception $e2) {
66
+ $this->assertSame($e, $e2);
67
+ }
68
+ }
69
+
70
+ /**
71
+ * @expectedException \InvalidArgumentException
72
+ */
73
+ public function testCannotResolveWithPromise()
74
+ {
75
+ new RejectedPromise(new Promise());
76
+ }
77
+
78
+ public function testReturnsSelfWhenNoOnReject()
79
+ {
80
+ $p = new RejectedPromise('a');
81
+ $this->assertSame($p, $p->then());
82
+ }
83
+
84
+ public function testInvokesOnRejectedAsynchronously()
85
+ {
86
+ $p = new RejectedPromise('a');
87
+ $r = null;
88
+ $f = function ($reason) use (&$r) { $r = $reason; };
89
+ $p->then(null, $f);
90
+ $this->assertNull($r);
91
+ \GuzzleHttp\Promise\queue()->run();
92
+ $this->assertEquals('a', $r);
93
+ }
94
+
95
+ public function testReturnsNewRejectedWhenOnRejectedFails()
96
+ {
97
+ $p = new RejectedPromise('a');
98
+ $f = function () { throw new \Exception('b'); };
99
+ $p2 = $p->then(null, $f);
100
+ $this->assertNotSame($p, $p2);
101
+ try {
102
+ $p2->wait();
103
+ $this->fail();
104
+ } catch (\Exception $e) {
105
+ $this->assertEquals('b', $e->getMessage());
106
+ }
107
+ }
108
+
109
+ public function testWaitingIsNoOp()
110
+ {
111
+ $p = new RejectedPromise('a');
112
+ $p->wait(false);
113
+ }
114
+
115
+ public function testOtherwiseIsSugarForRejections()
116
+ {
117
+ $p = new RejectedPromise('foo');
118
+ $p->otherwise(function ($v) use (&$c) { $c = $v; });
119
+ \GuzzleHttp\Promise\queue()->run();
120
+ $this->assertSame('foo', $c);
121
+ }
122
+
123
+ public function testCanResolveThenWithSuccess()
124
+ {
125
+ $actual = null;
126
+ $p = new RejectedPromise('foo');
127
+ $p->otherwise(function ($v) {
128
+ return $v . ' bar';
129
+ })->then(function ($v) use (&$actual) {
130
+ $actual = $v;
131
+ });
132
+ \GuzzleHttp\Promise\queue()->run();
133
+ $this->assertEquals('foo bar', $actual);
134
+ }
135
+
136
+ public function testDoesNotTryToRejectTwiceDuringTrampoline()
137
+ {
138
+ $fp = new RejectedPromise('a');
139
+ $t1 = $fp->then(null, function ($v) { return $v . ' b'; });
140
+ $t1->resolve('why!');
141
+ $this->assertEquals('why!', $t1->wait());
142
+ }
143
+ }
app/api/Ctct/vendor/guzzlehttp/promises/tests/RejectionExceptionTest.php ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Promise\Tests;
3
+
4
+ use GuzzleHttp\Promise\RejectionException;
5
+
6
+ class Thing1
7
+ {
8
+ public function __construct($message)
9
+ {
10
+ $this->message = $message;
11
+ }
12
+
13
+ public function __toString()
14
+ {
15
+ return $this->message;
16
+ }
17
+ }
18
+
19
+ class Thing2 implements \JsonSerializable
20
+ {
21
+ public function jsonSerialize()
22
+ {
23
+ return '{}';
24
+ }
25
+ }
26
+
27
+ /**
28
+ * @covers GuzzleHttp\Promise\RejectionException
29
+ */
30
+ class RejectionExceptionTest extends \PHPUnit_Framework_TestCase
31
+ {
32
+ public function testCanGetReasonFromException()
33
+ {
34
+ $thing = new Thing1('foo');
35
+ $e = new RejectionException($thing);
36
+
37
+ $this->assertSame($thing, $e->getReason());
38
+ $this->assertEquals('The promise was rejected with reason: foo', $e->getMessage());
39
+ }
40
+
41
+ public function testCanGetReasonMessageFromJson()
42
+ {
43
+ $reason = new Thing2();
44
+ $e = new RejectionException($reason);
45
+ $this->assertContains("{}", $e->getMessage());
46
+ }
47
+ }
app/api/Ctct/vendor/guzzlehttp/promises/tests/TaskQueueTest.php ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Promise\Test;
3
+
4
+ use GuzzleHttp\Promise\TaskQueue;
5
+
6
+ class TaskQueueTest extends \PHPUnit_Framework_TestCase
7
+ {
8
+ public function testKnowsIfEmpty()
9
+ {
10
+ $tq = new TaskQueue(false);
11
+ $this->assertTrue($tq->isEmpty());
12
+ }
13
+
14
+ public function testKnowsIfFull()
15
+ {
16
+ $tq = new TaskQueue(false);
17
+ $tq->add(function () {});
18
+ $this->assertFalse($tq->isEmpty());
19
+ }
20
+
21
+ public function testExecutesTasksInOrder()
22
+ {
23
+ $tq = new TaskQueue(false);
24
+ $called = [];
25
+ $tq->add(function () use (&$called) { $called[] = 'a'; });
26
+ $tq->add(function () use (&$called) { $called[] = 'b'; });
27
+ $tq->add(function () use (&$called) { $called[] = 'c'; });
28
+ $tq->run();
29
+ $this->assertEquals(['a', 'b', 'c'], $called);
30
+ }
31
+ }
app/api/Ctct/vendor/guzzlehttp/promises/tests/Thennable.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Promise\Tests;
3
+
4
+ use GuzzleHttp\Promise\Promise;
5
+
6
+ class Thennable
7
+ {
8
+ private $nextPromise = null;
9
+
10
+ public function __construct()
11
+ {
12
+ $this->nextPromise = new Promise();
13
+ }
14
+
15
+ public function then(callable $res = null, callable $rej = null)
16
+ {
17
+ return $this->nextPromise->then($res, $rej);
18
+ }
19
+
20
+ public function resolve($value)
21
+ {
22
+ $this->nextPromise->resolve($value);
23
+ }
24
+ }
app/api/Ctct/vendor/guzzlehttp/promises/tests/bootstrap.php ADDED
@@ -0,0 +1,4 @@
 
 
 
 
1
+ <?php
2
+ require __DIR__ . '/../vendor/autoload.php';
3
+ require __DIR__ . '/Thennable.php';
4
+ require __DIR__ . '/NotPromiseInstance.php';
app/api/Ctct/vendor/guzzlehttp/promises/tests/functionsTest.php ADDED
@@ -0,0 +1,694 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Promise\Tests;
3
+
4
+ use GuzzleHttp\Promise as P;
5
+ use GuzzleHttp\Promise\FulfilledPromise;
6
+ use GuzzleHttp\Promise\Promise;
7
+ use GuzzleHttp\Promise\RejectedPromise;
8
+
9
+ class FunctionsTest extends \PHPUnit_Framework_TestCase
10
+ {
11
+ public function testCreatesPromiseForValue()
12
+ {
13
+ $p = \GuzzleHttp\Promise\promise_for('foo');
14
+ $this->assertInstanceOf('GuzzleHttp\Promise\FulfilledPromise', $p);
15
+ }
16
+
17
+ public function testReturnsPromiseForPromise()
18
+ {
19
+ $p = new Promise();
20
+ $this->assertSame($p, \GuzzleHttp\Promise\promise_for($p));
21
+ }
22
+
23
+ public function testReturnsPromiseForThennable()
24
+ {
25
+ $p = new Thennable();
26
+ $wrapped = \GuzzleHttp\Promise\promise_for($p);
27
+ $this->assertNotSame($p, $wrapped);
28
+ $this->assertInstanceOf('GuzzleHttp\Promise\PromiseInterface', $wrapped);
29
+ $p->resolve('foo');
30
+ P\queue()->run();
31
+ $this->assertEquals('foo', $wrapped->wait());
32
+ }
33
+
34
+ public function testReturnsRejection()
35
+ {
36
+ $p = \GuzzleHttp\Promise\rejection_for('fail');
37
+ $this->assertInstanceOf('GuzzleHttp\Promise\RejectedPromise', $p);
38
+ $this->assertEquals('fail', $this->readAttribute($p, 'reason'));
39
+ }
40
+
41
+ public function testReturnsPromisesAsIsInRejectionFor()
42
+ {
43
+ $a = new Promise();
44
+ $b = \GuzzleHttp\Promise\rejection_for($a);
45
+ $this->assertSame($a, $b);
46
+ }
47
+
48
+ public function testWaitsOnAllPromisesIntoArray()
49
+ {
50
+ $e = new \Exception();
51
+ $a = new Promise(function () use (&$a) { $a->resolve('a'); });
52
+ $b = new Promise(function () use (&$b) { $b->reject('b'); });
53
+ $c = new Promise(function () use (&$c, $e) { $c->reject($e); });
54
+ $results = \GuzzleHttp\Promise\inspect_all([$a, $b, $c]);
55
+ $this->assertEquals([
56
+ ['state' => 'fulfilled', 'value' => 'a'],
57
+ ['state' => 'rejected', 'reason' => 'b'],
58
+ ['state' => 'rejected', 'reason' => $e]
59
+ ], $results);
60
+ }
61
+
62
+ /**
63
+ * @expectedException \GuzzleHttp\Promise\RejectionException
64
+ */
65
+ public function testUnwrapsPromisesWithNoDefaultAndFailure()
66
+ {
67
+ $promises = [new FulfilledPromise('a'), new Promise()];
68
+ \GuzzleHttp\Promise\unwrap($promises);
69
+ }
70
+
71
+ public function testUnwrapsPromisesWithNoDefault()
72
+ {
73
+ $promises = [new FulfilledPromise('a')];
74
+ $this->assertEquals(['a'], \GuzzleHttp\Promise\unwrap($promises));
75
+ }
76
+
77
+ public function testUnwrapsPromisesWithKeys()
78
+ {
79
+ $promises = [
80
+ 'foo' => new FulfilledPromise('a'),
81
+ 'bar' => new FulfilledPromise('b'),
82
+ ];
83
+ $this->assertEquals([
84
+ 'foo' => 'a',
85
+ 'bar' => 'b'
86
+ ], \GuzzleHttp\Promise\unwrap($promises));
87
+ }
88
+
89
+ public function testAllAggregatesSortedArray()
90
+ {
91
+ $a = new Promise();
92
+ $b = new Promise();
93
+ $c = new Promise();
94
+ $d = \GuzzleHttp\Promise\all([$a, $b, $c]);
95
+ $b->resolve('b');
96
+ $a->resolve('a');
97
+ $c->resolve('c');
98
+ $d->then(
99
+ function ($value) use (&$result) { $result = $value; },
100
+ function ($reason) use (&$result) { $result = $reason; }
101
+ );
102
+ P\queue()->run();
103
+ $this->assertEquals(['a', 'b', 'c'], $result);
104
+ }
105
+
106
+ public function testAllThrowsWhenAnyRejected()
107
+ {
108
+ $a = new Promise();
109
+ $b = new Promise();
110
+ $c = new Promise();
111
+ $d = \GuzzleHttp\Promise\all([$a, $b, $c]);
112
+ $b->resolve('b');
113
+ $a->reject('fail');
114
+ $c->resolve('c');
115
+ $d->then(
116
+ function ($value) use (&$result) { $result = $value; },
117
+ function ($reason) use (&$result) { $result = $reason; }
118
+ );
119
+ P\queue()->run();
120
+ $this->assertEquals('fail', $result);
121
+ }
122
+
123
+ public function testSomeAggregatesSortedArrayWithMax()
124
+ {
125
+ $a = new Promise();
126
+ $b = new Promise();
127
+ $c = new Promise();
128
+ $d = \GuzzleHttp\Promise\some(2, [$a, $b, $c]);
129
+ $b->resolve('b');
130
+ $c->resolve('c');
131
+ $a->resolve('a');
132
+ $d->then(function ($value) use (&$result) { $result = $value; });
133
+ P\queue()->run();
134
+ $this->assertEquals(['b', 'c'], $result);
135
+ }
136
+
137
+ public function testSomeRejectsWhenTooManyRejections()
138
+ {
139
+ $a = new Promise();
140
+ $b = new Promise();
141
+ $d = \GuzzleHttp\Promise\some(2, [$a, $b]);
142
+ $a->reject('bad');
143
+ $b->resolve('good');
144
+ P\queue()->run();
145
+ $this->assertEquals($a::REJECTED, $d->getState());
146
+ $d->then(null, function ($reason) use (&$called) {
147
+ $called = $reason;
148
+ });
149
+ P\queue()->run();
150
+ $this->assertInstanceOf('GuzzleHttp\Promise\AggregateException', $called);
151
+ $this->assertContains('bad', $called->getReason());
152
+ }
153
+
154
+ public function testCanWaitUntilSomeCountIsSatisfied()
155
+ {
156
+ $a = new Promise(function () use (&$a) { $a->resolve('a'); });
157
+ $b = new Promise(function () use (&$b) { $b->resolve('b'); });
158
+ $c = new Promise(function () use (&$c) { $c->resolve('c'); });
159
+ $d = \GuzzleHttp\Promise\some(2, [$a, $b, $c]);
160
+ $this->assertEquals(['a', 'b'], $d->wait());
161
+ }
162
+
163
+ /**
164
+ * @expectedException \GuzzleHttp\Promise\AggregateException
165
+ * @expectedExceptionMessage Not enough promises to fulfill count
166
+ */
167
+ public function testThrowsIfImpossibleToWaitForSomeCount()
168
+ {
169
+ $a = new Promise(function () use (&$a) { $a->resolve('a'); });
170
+ $d = \GuzzleHttp\Promise\some(2, [$a]);
171
+ $d->wait();
172
+ }
173
+
174
+ /**
175
+ * @expectedException \GuzzleHttp\Promise\AggregateException
176
+ * @expectedExceptionMessage Not enough promises to fulfill count
177
+ */
178
+ public function testThrowsIfResolvedWithoutCountTotalResults()
179
+ {
180
+ $a = new Promise();
181
+ $b = new Promise();
182
+ $d = \GuzzleHttp\Promise\some(3, [$a, $b]);
183
+ $a->resolve('a');
184
+ $b->resolve('b');
185
+ $d->wait();
186
+ }
187
+
188
+ public function testAnyReturnsFirstMatch()
189
+ {
190
+ $a = new Promise();
191
+ $b = new Promise();
192
+ $c = \GuzzleHttp\Promise\any([$a, $b]);
193
+ $b->resolve('b');
194
+ $a->resolve('a');
195
+ //P\queue()->run();
196
+ //$this->assertEquals('fulfilled', $c->getState());
197
+ $c->then(function ($value) use (&$result) { $result = $value; });
198
+ P\queue()->run();
199
+ $this->assertEquals('b', $result);
200
+ }
201
+
202
+ public function testSettleFulfillsWithFulfilledAndRejected()
203
+ {
204
+ $a = new Promise();
205
+ $b = new Promise();
206
+ $c = new Promise();
207
+ $d = \GuzzleHttp\Promise\settle([$a, $b, $c]);
208
+ $b->resolve('b');
209
+ $c->resolve('c');
210
+ $a->reject('a');
211
+ P\queue()->run();
212
+ $this->assertEquals('fulfilled', $d->getState());
213
+ $d->then(function ($value) use (&$result) { $result = $value; });
214
+ P\queue()->run();
215
+ $this->assertEquals([
216
+ ['state' => 'rejected', 'reason' => 'a'],
217
+ ['state' => 'fulfilled', 'value' => 'b'],
218
+ ['state' => 'fulfilled', 'value' => 'c']
219
+ ], $result);
220
+ }
221
+
222
+ public function testCanInspectFulfilledPromise()
223
+ {
224
+ $p = new FulfilledPromise('foo');
225
+ $this->assertEquals([
226
+ 'state' => 'fulfilled',
227
+ 'value' => 'foo'
228
+ ], \GuzzleHttp\Promise\inspect($p));
229
+ }
230
+
231
+ public function testCanInspectRejectedPromise()
232
+ {
233
+ $p = new RejectedPromise('foo');
234
+ $this->assertEquals([
235
+ 'state' => 'rejected',
236
+ 'reason' => 'foo'
237
+ ], \GuzzleHttp\Promise\inspect($p));
238
+ }
239
+
240
+ public function testCanInspectRejectedPromiseWithNormalException()
241
+ {
242
+ $e = new \Exception('foo');
243
+ $p = new RejectedPromise($e);
244
+ $this->assertEquals([
245
+ 'state' => 'rejected',
246
+ 'reason' => $e
247
+ ], \GuzzleHttp\Promise\inspect($p));
248
+ }
249
+
250
+ public function testCallsEachLimit()
251
+ {
252
+ $p = new Promise();
253
+ $aggregate = \GuzzleHttp\Promise\each_limit($p, 2);
254
+ $p->resolve('a');
255
+ P\queue()->run();
256
+ $this->assertEquals($p::FULFILLED, $aggregate->getState());
257
+ }
258
+
259
+ public function testEachLimitAllRejectsOnFailure()
260
+ {
261
+ $p = [new FulfilledPromise('a'), new RejectedPromise('b')];
262
+ $aggregate = \GuzzleHttp\Promise\each_limit_all($p, 2);
263
+ P\queue()->run();
264
+ $this->assertEquals(P\PromiseInterface::REJECTED, $aggregate->getState());
265
+ $result = \GuzzleHttp\Promise\inspect($aggregate);
266
+ $this->assertEquals('b', $result['reason']);
267
+ }
268
+
269
+ public function testIterForReturnsIterator()
270
+ {
271
+ $iter = new \ArrayIterator();
272
+ $this->assertSame($iter, \GuzzleHttp\Promise\iter_for($iter));
273
+ }
274
+
275
+ public function testKnowsIfFulfilled()
276
+ {
277
+ $p = new FulfilledPromise(null);
278
+ $this->assertTrue(P\is_fulfilled($p));
279
+ $this->assertFalse(P\is_rejected($p));
280
+ }
281
+
282
+ public function testKnowsIfRejected()
283
+ {
284
+ $p = new RejectedPromise(null);
285
+ $this->assertTrue(P\is_rejected($p));
286
+ $this->assertFalse(P\is_fulfilled($p));
287
+ }
288
+
289
+ public function testKnowsIfSettled()
290
+ {
291
+ $p = new RejectedPromise(null);
292
+ $this->assertTrue(P\is_settled($p));
293
+ $p = new Promise();
294
+ $this->assertFalse(P\is_settled($p));
295
+ }
296
+
297
+ public function testReturnsTrampoline()
298
+ {
299
+ $this->assertInstanceOf('GuzzleHttp\Promise\TaskQueue', P\queue());
300
+ $this->assertSame(P\queue(), P\queue());
301
+ }
302
+
303
+ public function testCanScheduleThunk()
304
+ {
305
+ $tramp = P\queue();
306
+ $promise = P\task(function () { return 'Hi!'; });
307
+ $c = null;
308
+ $promise->then(function ($v) use (&$c) { $c = $v; });
309
+ $this->assertNull($c);
310
+ $tramp->run();
311
+ $this->assertEquals('Hi!', $c);
312
+ }
313
+
314
+ public function testCanScheduleThunkWithRejection()
315
+ {
316
+ $tramp = P\queue();
317
+ $promise = P\task(function () { throw new \Exception('Hi!'); });
318
+ $c = null;
319
+ $promise->otherwise(function ($v) use (&$c) { $c = $v; });
320
+ $this->assertNull($c);
321
+ $tramp->run();
322
+ $this->assertEquals('Hi!', $c->getMessage());
323
+ }
324
+
325
+ public function testCanScheduleThunkWithWait()
326
+ {
327
+ $tramp = P\queue();
328
+ $promise = P\task(function () { return 'a'; });
329
+ $this->assertEquals('a', $promise->wait());
330
+ $tramp->run();
331
+ }
332
+
333
+ public function testYieldsFromCoroutine()
334
+ {
335
+ $promise = P\coroutine(function () {
336
+ $value = (yield new P\FulfilledPromise('a'));
337
+ yield $value . 'b';
338
+ });
339
+ $promise->then(function ($value) use (&$result) { $result = $value; });
340
+ P\queue()->run();
341
+ $this->assertEquals('ab', $result);
342
+ }
343
+
344
+ public function testCanCatchExceptionsInCoroutine()
345
+ {
346
+ $promise = P\coroutine(function () {
347
+ try {
348
+ yield new P\RejectedPromise('a');
349
+ $this->fail('Should have thrown into the coroutine!');
350
+ } catch (P\RejectionException $e) {
351
+ $value = (yield new P\FulfilledPromise($e->getReason()));
352
+ yield $value . 'b';
353
+ }
354
+ });
355
+ $promise->then(function ($value) use (&$result) { $result = $value; });
356
+ P\queue()->run();
357
+ $this->assertEquals(P\PromiseInterface::FULFILLED, $promise->getState());
358
+ $this->assertEquals('ab', $result);
359
+ }
360
+
361
+ public function testRejectsParentExceptionWhenException()
362
+ {
363
+ $promise = P\coroutine(function () {
364
+ yield new P\FulfilledPromise(0);
365
+ throw new \Exception('a');
366
+ });
367
+ $promise->then(
368
+ function () { $this->fail(); },
369
+ function ($reason) use (&$result) { $result = $reason; }
370
+ );
371
+ P\queue()->run();
372
+ $this->assertInstanceOf('Exception', $result);
373
+ $this->assertEquals('a', $result->getMessage());
374
+ }
375
+
376
+ public function testCanRejectFromRejectionCallback()
377
+ {
378
+ $promise = P\coroutine(function () {
379
+ yield new P\FulfilledPromise(0);
380
+ yield new P\RejectedPromise('no!');
381
+ });
382
+ $promise->then(
383
+ function () { $this->fail(); },
384
+ function ($reason) use (&$result) { $result = $reason; }
385
+ );
386
+ P\queue()->run();
387
+ $this->assertInstanceOf('GuzzleHttp\Promise\RejectionException', $result);
388
+ $this->assertEquals('no!', $result->getReason());
389
+ }
390
+
391
+ public function testCanAsyncReject()
392
+ {
393
+ $rej = new P\Promise();
394
+ $promise = P\coroutine(function () use ($rej) {
395
+ yield new P\FulfilledPromise(0);
396
+ yield $rej;
397
+ });
398
+ $promise->then(
399
+ function () { $this->fail(); },
400
+ function ($reason) use (&$result) { $result = $reason; }
401
+ );
402
+ $rej->reject('no!');
403
+ P\queue()->run();
404
+ $this->assertInstanceOf('GuzzleHttp\Promise\RejectionException', $result);
405
+ $this->assertEquals('no!', $result->getReason());
406
+ }
407
+
408
+ public function testCanCatchAndThrowOtherException()
409
+ {
410
+ $promise = P\coroutine(function () {
411
+ try {
412
+ yield new P\RejectedPromise('a');
413
+ $this->fail('Should have thrown into the coroutine!');
414
+ } catch (P\RejectionException $e) {
415
+ throw new \Exception('foo');
416
+ }
417
+ });
418
+ $promise->otherwise(function ($value) use (&$result) { $result = $value; });
419
+ P\queue()->run();
420
+ $this->assertEquals(P\PromiseInterface::REJECTED, $promise->getState());
421
+ $this->assertContains('foo', $result->getMessage());
422
+ }
423
+
424
+ public function testCanCatchAndYieldOtherException()
425
+ {
426
+ $promise = P\coroutine(function () {
427
+ try {
428
+ yield new P\RejectedPromise('a');
429
+ $this->fail('Should have thrown into the coroutine!');
430
+ } catch (P\RejectionException $e) {
431
+ yield new P\RejectedPromise('foo');
432
+ }
433
+ });
434
+ $promise->otherwise(function ($value) use (&$result) { $result = $value; });
435
+ P\queue()->run();
436
+ $this->assertEquals(P\PromiseInterface::REJECTED, $promise->getState());
437
+ $this->assertContains('foo', $result->getMessage());
438
+ }
439
+
440
+ public function createLotsOfSynchronousPromise()
441
+ {
442
+ return P\coroutine(function () {
443
+ $value = 0;
444
+ for ($i = 0; $i < 1000; $i++) {
445
+ $value = (yield new P\FulfilledPromise($i));
446
+ }
447
+ yield $value;
448
+ });
449
+ }
450
+
451
+ public function testLotsOfSynchronousDoesNotBlowStack()
452
+ {
453
+ $promise = $this->createLotsOfSynchronousPromise();
454
+ $promise->then(function ($v) use (&$r) { $r = $v; });
455
+ P\queue()->run();
456
+ $this->assertEquals(999, $r);
457
+ }
458
+
459
+ public function testLotsOfSynchronousWaitDoesNotBlowStack()
460
+ {
461
+ $promise = $this->createLotsOfSynchronousPromise();
462
+ $promise->then(function ($v) use (&$r) { $r = $v; });
463
+ $this->assertEquals(999, $promise->wait());
464
+ $this->assertEquals(999, $r);
465
+ }
466
+
467
+ private function createLotsOfFlappingPromise()
468
+ {
469
+ return P\coroutine(function () {
470
+ $value = 0;
471
+ for ($i = 0; $i < 1000; $i++) {
472
+ try {
473
+ if ($i % 2) {
474
+ $value = (yield new P\FulfilledPromise($i));
475
+ } else {
476
+ $value = (yield new P\RejectedPromise($i));
477
+ }
478
+ } catch (\Exception $e) {
479
+ $value = (yield new P\FulfilledPromise($i));
480
+ }
481
+ }
482
+ yield $value;
483
+ });
484
+ }
485
+
486
+ public function testLotsOfTryCatchingDoesNotBlowStack()
487
+ {
488
+ $promise = $this->createLotsOfFlappingPromise();
489
+ $promise->then(function ($v) use (&$r) { $r = $v; });
490
+ P\queue()->run();
491
+ $this->assertEquals(999, $r);
492
+ }
493
+
494
+ public function testLotsOfTryCatchingWaitingDoesNotBlowStack()
495
+ {
496
+ $promise = $this->createLotsOfFlappingPromise();
497
+ $promise->then(function ($v) use (&$r) { $r = $v; });
498
+ $this->assertEquals(999, $promise->wait());
499
+ $this->assertEquals(999, $r);
500
+ }
501
+
502
+ public function testAsyncPromisesWithCorrectlyYieldedValues()
503
+ {
504
+ $promises = [
505
+ new P\Promise(),
506
+ new P\Promise(),
507
+ new P\Promise()
508
+ ];
509
+
510
+ $promise = P\coroutine(function () use ($promises) {
511
+ $value = null;
512
+ $this->assertEquals('skip', (yield new P\FulfilledPromise('skip')));
513
+ foreach ($promises as $idx => $p) {
514
+ $value = (yield $p);
515
+ $this->assertEquals($value, $idx);
516
+ $this->assertEquals('skip', (yield new P\FulfilledPromise('skip')));
517
+ }
518
+ $this->assertEquals('skip', (yield new P\FulfilledPromise('skip')));
519
+ yield $value;
520
+ });
521
+
522
+ $promises[0]->resolve(0);
523
+ $promises[1]->resolve(1);
524
+ $promises[2]->resolve(2);
525
+
526
+ $promise->then(function ($v) use (&$r) { $r = $v; });
527
+ P\queue()->run();
528
+ $this->assertEquals(2, $r);
529
+ }
530
+
531
+ public function testYieldFinalWaitablePromise()
532
+ {
533
+ $p1 = new P\Promise(function () use (&$p1) {
534
+ $p1->resolve('skip me');
535
+ });
536
+ $p2 = new P\Promise(function () use (&$p2) {
537
+ $p2->resolve('hello!');
538
+ });
539
+ $co = P\coroutine(function() use ($p1, $p2) {
540
+ yield $p1;
541
+ yield $p2;
542
+ });
543
+ P\queue()->run();
544
+ $this->assertEquals('hello!', $co->wait());
545
+ }
546
+
547
+ public function testCanYieldFinalPendingPromise()
548
+ {
549
+ $p1 = new P\Promise();
550
+ $p2 = new P\Promise();
551
+ $co = P\coroutine(function() use ($p1, $p2) {
552
+ yield $p1;
553
+ yield $p2;
554
+ });
555
+ $p1->resolve('a');
556
+ $p2->resolve('b');
557
+ $co->then(function ($value) use (&$result) { $result = $value; });
558
+ P\queue()->run();
559
+ $this->assertEquals('b', $result);
560
+ }
561
+
562
+ public function testCanNestYieldsAndFailures()
563
+ {
564
+ $p1 = new P\Promise();
565
+ $p2 = new P\Promise();
566
+ $p3 = new P\Promise();
567
+ $p4 = new P\Promise();
568
+ $p5 = new P\Promise();
569
+ $co = P\coroutine(function() use ($p1, $p2, $p3, $p4, $p5) {
570
+ try {
571
+ yield $p1;
572
+ } catch (\Exception $e) {
573
+ yield $p2;
574
+ try {
575
+ yield $p3;
576
+ yield $p4;
577
+ } catch (\Exception $e) {
578
+ yield $p5;
579
+ }
580
+ }
581
+ });
582
+ $p1->reject('a');
583
+ $p2->resolve('b');
584
+ $p3->resolve('c');
585
+ $p4->reject('d');
586
+ $p5->resolve('e');
587
+ $co->then(function ($value) use (&$result) { $result = $value; });
588
+ P\queue()->run();
589
+ $this->assertEquals('e', $result);
590
+ }
591
+
592
+ public function testCanYieldErrorsAndSuccessesWithoutRecursion()
593
+ {
594
+ $promises = [];
595
+ for ($i = 0; $i < 20; $i++) {
596
+ $promises[] = new P\Promise();
597
+ }
598
+
599
+ $co = P\coroutine(function() use ($promises) {
600
+ for ($i = 0; $i < 20; $i += 4) {
601
+ try {
602
+ yield $promises[$i];
603
+ yield $promises[$i + 1];
604
+ } catch (\Exception $e) {
605
+ yield $promises[$i + 2];
606
+ yield $promises[$i + 3];
607
+ }
608
+ }
609
+ });
610
+
611
+ for ($i = 0; $i < 20; $i += 4) {
612
+ $promises[$i]->resolve($i);
613
+ $promises[$i + 1]->reject($i + 1);
614
+ $promises[$i + 2]->resolve($i + 2);
615
+ $promises[$i + 3]->resolve($i + 3);
616
+ }
617
+
618
+ $co->then(function ($value) use (&$result) { $result = $value; });
619
+ P\queue()->run();
620
+ $this->assertEquals('19', $result);
621
+ }
622
+
623
+ public function testCanWaitOnPromiseAfterFulfilled()
624
+ {
625
+ $f = function () {
626
+ static $i = 0;
627
+ $i++;
628
+ return $p = new P\Promise(function () use (&$p, $i) {
629
+ $p->resolve($i . '-bar');
630
+ });
631
+ };
632
+
633
+ $promises = [];
634
+ for ($i = 0; $i < 20; $i++) {
635
+ $promises[] = $f();
636
+ }
637
+
638
+ $p = P\coroutine(function () use ($promises) {
639
+ yield new P\FulfilledPromise('foo!');
640
+ foreach ($promises as $promise) {
641
+ yield $promise;
642
+ }
643
+ });
644
+
645
+ $this->assertEquals('20-bar', $p->wait());
646
+ }
647
+
648
+ public function testCanWaitOnErroredPromises()
649
+ {
650
+ $p1 = new P\Promise(function () use (&$p1) { $p1->reject('a'); });
651
+ $p2 = new P\Promise(function () use (&$p2) { $p2->resolve('b'); });
652
+ $p3 = new P\Promise(function () use (&$p3) { $p3->resolve('c'); });
653
+ $p4 = new P\Promise(function () use (&$p4) { $p4->reject('d'); });
654
+ $p5 = new P\Promise(function () use (&$p5) { $p5->resolve('e'); });
655
+ $p6 = new P\Promise(function () use (&$p6) { $p6->reject('f'); });
656
+
657
+ $co = P\coroutine(function() use ($p1, $p2, $p3, $p4, $p5, $p6) {
658
+ try {
659
+ yield $p1;
660
+ } catch (\Exception $e) {
661
+ yield $p2;
662
+ try {
663
+ yield $p3;
664
+ yield $p4;
665
+ } catch (\Exception $e) {
666
+ yield $p5;
667
+ yield $p6;
668
+ }
669
+ }
670
+ });
671
+
672
+ $res = P\inspect($co);
673
+ $this->assertEquals('f', $res['reason']);
674
+ }
675
+
676
+ public function testCoroutineOtherwiseIntegrationTest()
677
+ {
678
+ $a = new P\Promise();
679
+ $b = new P\Promise();
680
+ $promise = P\coroutine(function () use ($a, $b) {
681
+ // Execute the pool of commands concurrently, and process errors.
682
+ yield $a;
683
+ yield $b;
684
+ })->otherwise(function (\Exception $e) {
685
+ // Throw errors from the operations as a specific Multipart error.
686
+ throw new \OutOfBoundsException('a', 0, $e);
687
+ });
688
+ $a->resolve('a');
689
+ $b->reject('b');
690
+ $reason = P\inspect($promise)['reason'];
691
+ $this->assertInstanceOf('OutOfBoundsException', $reason);
692
+ $this->assertInstanceOf('GuzzleHttp\Promise\RejectionException', $reason->getPrevious());
693
+ }
694
+ }
app/api/Ctct/vendor/guzzlehttp/psr7/.gitignore ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ phpunit.xml
2
+ composer.phar
3
+ composer.lock
4
+ composer-test.lock
5
+ vendor/
6
+ build/artifacts/
7
+ artifacts/
8
+ docs/_build
9
+ docs/*.pyc
10
+ .idea
11
+ .DS_STORE
app/api/Ctct/vendor/guzzlehttp/psr7/.travis.yml ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ language: php
2
+
3
+ php:
4
+ - 5.4
5
+ - 5.5
6
+ - 5.6
7
+ - 7.0
8
+ - hhvm
9
+
10
+ sudo: false
11
+
12
+ install:
13
+ - travis_retry composer install --no-interaction --prefer-source
14
+
15
+ script: make test
16
+
17
+ matrix:
18
+ allow_failures:
19
+ - php: hhvm
20
+ fast_finish: true
app/api/Ctct/vendor/guzzlehttp/psr7/CHANGELOG.md ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # CHANGELOG
2
+
3
+ ## 1.2.2 - 2016-01-22
4
+
5
+ * Added support for URIs without any authority.
6
+ * Added support for HTTP 451 'Unavailable For Legal Reasons.'
7
+ * Added support for using '0' as a filename.
8
+ * Added support for including non-standard ports in Host headers.
9
+
10
+ ## 1.2.1 - 2015-11-02
11
+
12
+ * Now supporting negative offsets when seeking to SEEK_END.
13
+
14
+ ## 1.2.0 - 2015-08-15
15
+
16
+ * Body as `"0"` is now properly added to a response.
17
+ * Now allowing forward seeking in CachingStream.
18
+ * Now properly parsing HTTP requests that contain proxy targets in
19
+ `parse_request`.
20
+ * functions.php is now conditionally required.
21
+ * user-info is no longer dropped when resolving URIs.
22
+
23
+ ## 1.1.0 - 2015-06-24
24
+
25
+ * URIs can now be relative.
26
+ * `multipart/form-data` headers are now overridden case-insensitively.
27
+ * URI paths no longer encode the following characters because they are allowed
28
+ in URIs: "(", ")", "*", "!", "'"
29
+ * A port is no longer added to a URI when the scheme is missing and no port is
30
+ present.
31
+
32
+ ## 1.0.0 - 2015-05-19
33
+
34
+ Initial release.
35
+
36
+ Currently unsupported:
37
+
38
+ - `Psr\Http\Message\ServerRequestInterface`
39
+ - `Psr\Http\Message\UploadedFileInterface`
app/api/Ctct/vendor/guzzlehttp/psr7/LICENSE ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Copyright (c) 2015 Michael Dowling, https://github.com/mtdowling <mtdowling@gmail.com>
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.
app/api/Ctct/vendor/guzzlehttp/psr7/Makefile ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ all: clean test
2
+
3
+ test:
4
+ vendor/bin/phpunit $(TEST)
5
+
6
+ coverage:
7
+ vendor/bin/phpunit --coverage-html=artifacts/coverage $(TEST)
8
+
9
+ view-coverage:
10
+ open artifacts/coverage/index.html
11
+
12
+ check-tag:
13
+ $(if $(TAG),,$(error TAG is not defined. Pass via "make tag TAG=4.2.1"))
14
+
15
+ tag: check-tag
16
+ @echo Tagging $(TAG)
17
+ chag update $(TAG)
18
+ git commit -a -m '$(TAG) release'
19
+ chag tag
20
+ @echo "Release has been created. Push using 'make release'"
21
+ @echo "Changes made in the release commit"
22
+ git diff HEAD~1 HEAD
23
+
24
+ release: check-tag
25
+ git push origin master
26
+ git push origin $(TAG)
27
+
28
+ clean:
29
+ rm -rf artifacts/*
app/api/Ctct/vendor/guzzlehttp/psr7/README.md ADDED
@@ -0,0 +1,583 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # PSR-7 Message Implementation
2
+
3
+ This repository contains a partial [PSR-7](http://www.php-fig.org/psr/psr-7/)
4
+ message implementation, several stream decorators, and some helpful
5
+ functionality like query string parsing. Currently missing
6
+ ServerRequestInterface and UploadedFileInterface; a pull request for these features is welcome.
7
+
8
+
9
+ [![Build Status](https://travis-ci.org/guzzle/psr7.svg?branch=master)](https://travis-ci.org/guzzle/psr7)
10
+
11
+
12
+ # Stream implementation
13
+
14
+ This package comes with a number of stream implementations and stream
15
+ decorators.
16
+
17
+
18
+ ## AppendStream
19
+
20
+ `GuzzleHttp\Psr7\AppendStream`
21
+
22
+ Reads from multiple streams, one after the other.
23
+
24
+ ```php
25
+ use GuzzleHttp\Psr7;
26
+
27
+ $a = Psr7\stream_for('abc, ');
28
+ $b = Psr7\stream_for('123.');
29
+ $composed = new Psr7\AppendStream([$a, $b]);
30
+
31
+ $composed->addStream(Psr7\stream_for(' Above all listen to me'));
32
+
33
+ echo $composed(); // abc, 123. Above all listen to me.
34
+ ```
35
+
36
+
37
+ ## BufferStream
38
+
39
+ `GuzzleHttp\Psr7\BufferStream`
40
+
41
+ Provides a buffer stream that can be written to to fill a buffer, and read
42
+ from to remove bytes from the buffer.
43
+
44
+ This stream returns a "hwm" metadata value that tells upstream consumers
45
+ what the configured high water mark of the stream is, or the maximum
46
+ preferred size of the buffer.
47
+
48
+ ```php
49
+ use GuzzleHttp\Psr7;
50
+
51
+ // When more than 1024 bytes are in the buffer, it will begin returning
52
+ // false to writes. This is an indication that writers should slow down.
53
+ $buffer = new Psr7\BufferStream(1024);
54
+ ```
55
+
56
+
57
+ ## CachingStream
58
+
59
+ The CachingStream is used to allow seeking over previously read bytes on
60
+ non-seekable streams. This can be useful when transferring a non-seekable
61
+ entity body fails due to needing to rewind the stream (for example, resulting
62
+ from a redirect). Data that is read from the remote stream will be buffered in
63
+ a PHP temp stream so that previously read bytes are cached first in memory,
64
+ then on disk.
65
+
66
+ ```php
67
+ use GuzzleHttp\Psr7;
68
+
69
+ $original = Psr7\stream_for(fopen('http://www.google.com', 'r'));
70
+ $stream = new Psr7\CachingStream($original);
71
+
72
+ $stream->read(1024);
73
+ echo $stream->tell();
74
+ // 1024
75
+
76
+ $stream->seek(0);
77
+ echo $stream->tell();
78
+ // 0
79
+ ```
80
+
81
+
82
+ ## DroppingStream
83
+
84
+ `GuzzleHttp\Psr7\DroppingStream`
85
+
86
+ Stream decorator that begins dropping data once the size of the underlying
87
+ stream becomes too full.
88
+
89
+ ```php
90
+ use GuzzleHttp\Psr7;
91
+
92
+ // Create an empty stream
93
+ $stream = Psr7\stream_for();
94
+
95
+ // Start dropping data when the stream has more than 10 bytes
96
+ $dropping = new Psr7\DroppingStream($stream, 10);
97
+
98
+ $stream->write('01234567890123456789');
99
+ echo $stream; // 0123456789
100
+ ```
101
+
102
+
103
+ ## FnStream
104
+
105
+ `GuzzleHttp\Psr7\FnStream`
106
+
107
+ Compose stream implementations based on a hash of functions.
108
+
109
+ Allows for easy testing and extension of a provided stream without needing to
110
+ to create a concrete class for a simple extension point.
111
+
112
+ ```php
113
+
114
+ use GuzzleHttp\Psr7;
115
+
116
+ $stream = Psr7\stream_for('hi');
117
+ $fnStream = Psr7\FnStream::decorate($stream, [
118
+ 'rewind' => function () use ($stream) {
119
+ echo 'About to rewind - ';
120
+ $stream->rewind();
121
+ echo 'rewound!';
122
+ }
123
+ ]);
124
+
125
+ $fnStream->rewind();
126
+ // Outputs: About to rewind - rewound!
127
+ ```
128
+
129
+
130
+ ## InflateStream
131
+
132
+ `GuzzleHttp\Psr7\InflateStream`
133
+
134
+ Uses PHP's zlib.inflate filter to inflate deflate or gzipped content.
135
+
136
+ This stream decorator skips the first 10 bytes of the given stream to remove
137
+ the gzip header, converts the provided stream to a PHP stream resource,
138
+ then appends the zlib.inflate filter. The stream is then converted back
139
+ to a Guzzle stream resource to be used as a Guzzle stream.
140
+
141
+
142
+ ## LazyOpenStream
143
+
144
+ `GuzzleHttp\Psr7\LazyOpenStream`
145
+
146
+ Lazily reads or writes to a file that is opened only after an IO operation
147
+ take place on the stream.
148
+
149
+ ```php
150
+ use GuzzleHttp\Psr7;
151
+
152
+ $stream = new Psr7\LazyOpenStream('/path/to/file', 'r');
153
+ // The file has not yet been opened...
154
+
155
+ echo $stream->read(10);
156
+ // The file is opened and read from only when needed.
157
+ ```
158
+
159
+
160
+ ## LimitStream
161
+
162
+ `GuzzleHttp\Psr7\LimitStream`
163
+
164
+ LimitStream can be used to read a subset or slice of an existing stream object.
165
+ This can be useful for breaking a large file into smaller pieces to be sent in
166
+ chunks (e.g. Amazon S3's multipart upload API).
167
+
168
+ ```php
169
+ use GuzzleHttp\Psr7;
170
+
171
+ $original = Psr7\stream_for(fopen('/tmp/test.txt', 'r+'));
172
+ echo $original->getSize();
173
+ // >>> 1048576
174
+
175
+ // Limit the size of the body to 1024 bytes and start reading from byte 2048
176
+ $stream = new Psr7\LimitStream($original, 1024, 2048);
177
+ echo $stream->getSize();
178
+ // >>> 1024
179
+ echo $stream->tell();
180
+ // >>> 0
181
+ ```
182
+
183
+
184
+ ## MultipartStream
185
+
186
+ `GuzzleHttp\Psr7\MultipartStream`
187
+
188
+ Stream that when read returns bytes for a streaming multipart or
189
+ multipart/form-data stream.
190
+
191
+
192
+ ## NoSeekStream
193
+
194
+ `GuzzleHttp\Psr7\NoSeekStream`
195
+
196
+ NoSeekStream wraps a stream and does not allow seeking.
197
+
198
+ ```php
199
+ use GuzzleHttp\Psr7;
200
+
201
+ $original = Psr7\stream_for('foo');
202
+ $noSeek = new Psr7\NoSeekStream($original);
203
+
204
+ echo $noSeek->read(3);
205
+ // foo
206
+ var_export($noSeek->isSeekable());
207
+ // false
208
+ $noSeek->seek(0);
209
+ var_export($noSeek->read(3));
210
+ // NULL
211
+ ```
212
+
213
+
214
+ ## PumpStream
215
+
216
+ `GuzzleHttp\Psr7\PumpStream`
217
+
218
+ Provides a read only stream that pumps data from a PHP callable.
219
+
220
+ When invoking the provided callable, the PumpStream will pass the amount of
221
+ data requested to read to the callable. The callable can choose to ignore
222
+ this value and return fewer or more bytes than requested. Any extra data
223
+ returned by the provided callable is buffered internally until drained using
224
+ the read() function of the PumpStream. The provided callable MUST return
225
+ false when there is no more data to read.
226
+
227
+
228
+ ## Implementing stream decorators
229
+
230
+ Creating a stream decorator is very easy thanks to the
231
+ `GuzzleHttp\Psr7\StreamDecoratorTrait`. This trait provides methods that
232
+ implement `Psr\Http\Message\StreamInterface` by proxying to an underlying
233
+ stream. Just `use` the `StreamDecoratorTrait` and implement your custom
234
+ methods.
235
+
236
+ For example, let's say we wanted to call a specific function each time the last
237
+ byte is read from a stream. This could be implemented by overriding the
238
+ `read()` method.
239
+
240
+ ```php
241
+ use Psr\Http\Message\StreamInterface;
242
+ use GuzzleHttp\Psr7\StreamDecoratorTrait;
243
+
244
+ class EofCallbackStream implements StreamInterface
245
+ {
246
+ use StreamDecoratorTrait;
247
+
248
+ private $callback;
249
+
250
+ public function __construct(StreamInterface $stream, callable $cb)
251
+ {
252
+ $this->stream = $stream;
253
+ $this->callback = $cb;
254
+ }
255
+
256
+ public function read($length)
257
+ {
258
+ $result = $this->stream->read($length);
259
+
260
+ // Invoke the callback when EOF is hit.
261
+ if ($this->eof()) {
262
+ call_user_func($this->callback);
263
+ }
264
+
265
+ return $result;
266
+ }
267
+ }
268
+ ```
269
+
270
+ This decorator could be added to any existing stream and used like so:
271
+
272
+ ```php
273
+ use GuzzleHttp\Psr7;
274
+
275
+ $original = Psr7\stream_for('foo');
276
+
277
+ $eofStream = new EofCallbackStream($original, function () {
278
+ echo 'EOF!';
279
+ });
280
+
281
+ $eofStream->read(2);
282
+ $eofStream->read(1);
283
+ // echoes "EOF!"
284
+ $eofStream->seek(0);
285
+ $eofStream->read(3);
286
+ // echoes "EOF!"
287
+ ```
288
+
289
+
290
+ ## PHP StreamWrapper
291
+
292
+ You can use the `GuzzleHttp\Psr7\StreamWrapper` class if you need to use a
293
+ PSR-7 stream as a PHP stream resource.
294
+
295
+ Use the `GuzzleHttp\Psr7\StreamWrapper::getResource()` method to create a PHP
296
+ stream from a PSR-7 stream.
297
+
298
+ ```php
299
+ use GuzzleHttp\Psr7\StreamWrapper;
300
+
301
+ $stream = GuzzleHttp\Psr7\stream_for('hello!');
302
+ $resource = StreamWrapper::getResource($stream);
303
+ echo fread($resource, 6); // outputs hello!
304
+ ```
305
+
306
+
307
+ # Function API
308
+
309
+ There are various functions available under the `GuzzleHttp\Psr7` namespace.
310
+
311
+
312
+ ## `function str`
313
+
314
+ `function str(MessageInterface $message)`
315
+
316
+ Returns the string representation of an HTTP message.
317
+
318
+ ```php
319
+ $request = new GuzzleHttp\Psr7\Request('GET', 'http://example.com');
320
+ echo GuzzleHttp\Psr7\str($request);
321
+ ```
322
+
323
+
324
+ ## `function uri_for`
325
+
326
+ `function uri_for($uri)`
327
+
328
+ This function accepts a string or `Psr\Http\Message\UriInterface` and returns a
329
+ UriInterface for the given value. If the value is already a `UriInterface`, it
330
+ is returned as-is.
331
+
332
+ ```php
333
+ $uri = GuzzleHttp\Psr7\uri_for('http://example.com');
334
+ assert($uri === GuzzleHttp\Psr7\uri_for($uri));
335
+ ```
336
+
337
+
338
+ ## `function stream_for`
339
+
340
+ `function stream_for($resource = '', array $options = [])`
341
+
342
+ Create a new stream based on the input type.
343
+
344
+ Options is an associative array that can contain the following keys:
345
+
346
+ * - metadata: Array of custom metadata.
347
+ * - size: Size of the stream.
348
+
349
+ This method accepts the following `$resource` types:
350
+
351
+ - `Psr\Http\Message\StreamInterface`: Returns the value as-is.
352
+ - `string`: Creates a stream object that uses the given string as the contents.
353
+ - `resource`: Creates a stream object that wraps the given PHP stream resource.
354
+ - `Iterator`: If the provided value implements `Iterator`, then a read-only
355
+ stream object will be created that wraps the given iterable. Each time the
356
+ stream is read from, data from the iterator will fill a buffer and will be
357
+ continuously called until the buffer is equal to the requested read size.
358
+ Subsequent read calls will first read from the buffer and then call `next`
359
+ on the underlying iterator until it is exhausted.
360
+ - `object` with `__toString()`: If the object has the `__toString()` method,
361
+ the object will be cast to a string and then a stream will be returned that
362
+ uses the string value.
363
+ - `NULL`: When `null` is passed, an empty stream object is returned.
364
+ - `callable` When a callable is passed, a read-only stream object will be
365
+ created that invokes the given callable. The callable is invoked with the
366
+ number of suggested bytes to read. The callable can return any number of
367
+ bytes, but MUST return `false` when there is no more data to return. The
368
+ stream object that wraps the callable will invoke the callable until the
369
+ number of requested bytes are available. Any additional bytes will be
370
+ buffered and used in subsequent reads.
371
+
372
+ ```php
373
+ $stream = GuzzleHttp\Psr7\stream_for('foo');
374
+ $stream = GuzzleHttp\Psr7\stream_for(fopen('/path/to/file', 'r'));
375
+
376
+ $generator function ($bytes) {
377
+ for ($i = 0; $i < $bytes; $i++) {
378
+ yield ' ';
379
+ }
380
+ }
381
+
382
+ $stream = GuzzleHttp\Psr7\stream_for($generator(100));
383
+ ```
384
+
385
+
386
+ ## `function parse_header`
387
+
388
+ `function parse_header($header)`
389
+
390
+ Parse an array of header values containing ";" separated data into an array of
391
+ associative arrays representing the header key value pair data of the header.
392
+ When a parameter does not contain a value, but just contains a key, this
393
+ function will inject a key with a '' string value.
394
+
395
+
396
+ ## `function normalize_header`
397
+
398
+ `function normalize_header($header)`
399
+
400
+ Converts an array of header values that may contain comma separated headers
401
+ into an array of headers with no comma separated values.
402
+
403
+
404
+ ## `function modify_request`
405
+
406
+ `function modify_request(RequestInterface $request, array $changes)`
407
+
408
+ Clone and modify a request with the given changes. This method is useful for
409
+ reducing the number of clones needed to mutate a message.
410
+
411
+ The changes can be one of:
412
+
413
+ - method: (string) Changes the HTTP method.
414
+ - set_headers: (array) Sets the given headers.
415
+ - remove_headers: (array) Remove the given headers.
416
+ - body: (mixed) Sets the given body.
417
+ - uri: (UriInterface) Set the URI.
418
+ - query: (string) Set the query string value of the URI.
419
+ - version: (string) Set the protocol version.
420
+
421
+
422
+ ## `function rewind_body`
423
+
424
+ `function rewind_body(MessageInterface $message)`
425
+
426
+ Attempts to rewind a message body and throws an exception on failure. The body
427
+ of the message will only be rewound if a call to `tell()` returns a value other
428
+ than `0`.
429
+
430
+
431
+ ## `function try_fopen`
432
+
433
+ `function try_fopen($filename, $mode)`
434
+
435
+ Safely opens a PHP stream resource using a filename.
436
+
437
+ When fopen fails, PHP normally raises a warning. This function adds an error
438
+ handler that checks for errors and throws an exception instead.
439
+
440
+
441
+ ## `function copy_to_string`
442
+
443
+ `function copy_to_string(StreamInterface $stream, $maxLen = -1)`
444
+
445
+ Copy the contents of a stream into a string until the given number of bytes
446
+ have been read.
447
+
448
+
449
+ ## `function copy_to_stream`
450
+
451
+ `function copy_to_stream(StreamInterface $source, StreamInterface $dest, $maxLen = -1)`
452
+
453
+ Copy the contents of a stream into another stream until the given number of
454
+ bytes have been read.
455
+
456
+
457
+ ## `function hash`
458
+
459
+ `function hash(StreamInterface $stream, $algo, $rawOutput = false)`
460
+
461
+ Calculate a hash of a Stream. This method reads the entire stream to calculate
462
+ a rolling hash (based on PHP's hash_init functions).
463
+
464
+
465
+ ## `function readline`
466
+
467
+ `function readline(StreamInterface $stream, $maxLength = null)`
468
+
469
+ Read a line from the stream up to the maximum allowed buffer length.
470
+
471
+
472
+ ## `function parse_request`
473
+
474
+ `function parse_request($message)`
475
+
476
+ Parses a request message string into a request object.
477
+
478
+
479
+ ## `function parse_response`
480
+
481
+ `function parse_response($message)`
482
+
483
+ Parses a response message string into a response object.
484
+
485
+
486
+ ## `function parse_query`
487
+
488
+ `function parse_query($str, $urlEncoding = true)`
489
+
490
+ Parse a query string into an associative array.
491
+
492
+ If multiple values are found for the same key, the value of that key value pair
493
+ will become an array. This function does not parse nested PHP style arrays into
494
+ an associative array (e.g., `foo[a]=1&foo[b]=2` will be parsed into
495
+ `['foo[a]' => '1', 'foo[b]' => '2']`).
496
+
497
+
498
+ ## `function build_query`
499
+
500
+ `function build_query(array $params, $encoding = PHP_QUERY_RFC3986)`
501
+
502
+ Build a query string from an array of key value pairs.
503
+
504
+ This function can use the return value of parseQuery() to build a query string.
505
+ This function does not modify the provided keys when an array is encountered
506
+ (like http_build_query would).
507
+
508
+
509
+ ## `function mimetype_from_filename`
510
+
511
+ `function mimetype_from_filename($filename)`
512
+
513
+ Determines the mimetype of a file by looking at its extension.
514
+
515
+
516
+ ## `function mimetype_from_extension`
517
+
518
+ `function mimetype_from_extension($extension)`
519
+
520
+ Maps a file extensions to a mimetype.
521
+
522
+
523
+ # Static URI methods
524
+
525
+ The `GuzzleHttp\Psr7\Uri` class has several static methods to manipulate URIs.
526
+
527
+
528
+ ## `GuzzleHttp\Psr7\Uri::removeDotSegments`
529
+
530
+ `public static function removeDotSegments($path) -> UriInterface`
531
+
532
+ Removes dot segments from a path and returns the new path.
533
+
534
+ See http://tools.ietf.org/html/rfc3986#section-5.2.4
535
+
536
+
537
+ ## `GuzzleHttp\Psr7\Uri::resolve`
538
+
539
+ `public static function resolve(UriInterface $base, $rel) -> UriInterface`
540
+
541
+ Resolve a base URI with a relative URI and return a new URI.
542
+
543
+ See http://tools.ietf.org/html/rfc3986#section-5
544
+
545
+
546
+ ## `GuzzleHttp\Psr7\Uri::withQueryValue`
547
+
548
+ `public static function withQueryValue(UriInterface $uri, $key, $value) -> UriInterface`
549
+
550
+ Create a new URI with a specific query string value.
551
+
552
+ Any existing query string values that exactly match the provided key are
553
+ removed and replaced with the given key value pair.
554
+
555
+ Note: this function will convert "=" to "%3D" and "&" to "%26".
556
+
557
+
558
+ ## `GuzzleHttp\Psr7\Uri::withoutQueryValue`
559
+
560
+ `public static function withoutQueryValue(UriInterface $uri, $key, $value) -> UriInterface`
561
+
562
+ Create a new URI with a specific query string value removed.
563
+
564
+ Any existing query string values that exactly match the provided key are
565
+ removed.
566
+
567
+ Note: this function will convert "=" to "%3D" and "&" to "%26".
568
+
569
+
570
+ ## `GuzzleHttp\Psr7\Uri::fromParts`
571
+
572
+ `public static function fromParts(array $parts) -> UriInterface`
573
+
574
+ Create a `GuzzleHttp\Psr7\Uri` object from a hash of `parse_url` parts.
575
+
576
+
577
+ # Not Implemented
578
+
579
+ A few aspects of PSR-7 are not implemented in this project. A pull request for
580
+ any of these features is welcome:
581
+
582
+ - `Psr\Http\Message\ServerRequestInterface`
583
+ - `Psr\Http\Message\UploadedFileInterface`
app/api/Ctct/vendor/guzzlehttp/psr7/composer.json ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "guzzlehttp/psr7",
3
+ "type": "library",
4
+ "description": "PSR-7 message implementation",
5
+ "keywords": ["message", "stream", "http", "uri"],
6
+ "license": "MIT",
7
+ "authors": [
8
+ {
9
+ "name": "Michael Dowling",
10
+ "email": "mtdowling@gmail.com",
11
+ "homepage": "https://github.com/mtdowling"
12
+ }
13
+ ],
14
+ "require": {
15
+ "php": ">=5.4.0",
16
+ "psr/http-message": "~1.0"
17
+ },
18
+ "require-dev": {
19
+ "phpunit/phpunit": "~4.0"
20
+ },
21
+ "provide": {
22
+ "psr/http-message-implementation": "1.0"
23
+ },
24
+ "autoload": {
25
+ "psr-4": {
26
+ "GuzzleHttp\\Psr7\\": "src/"
27
+ },
28
+ "files": ["src/functions_include.php"]
29
+ },
30
+ "extra": {
31
+ "branch-alias": {
32
+ "dev-master": "1.0-dev"
33
+ }
34
+ }
35
+ }
app/api/Ctct/vendor/guzzlehttp/psr7/phpunit.xml.dist ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <phpunit bootstrap="./tests/bootstrap.php"
3
+ colors="true">
4
+ <testsuites>
5
+ <testsuite>
6
+ <directory>tests</directory>
7
+ </testsuite>
8
+ </testsuites>
9
+ <filter>
10
+ <whitelist>
11
+ <directory suffix=".php">src</directory>
12
+ <exclude>
13
+ <directory suffix="Interface.php">src/</directory>
14
+ </exclude>
15
+ </whitelist>
16
+ </filter>
17
+ </phpunit>
app/api/Ctct/vendor/guzzlehttp/psr7/src/AppendStream.php ADDED
@@ -0,0 +1,233 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Psr7;
3
+
4
+ use Psr\Http\Message\StreamInterface;
5
+
6
+ /**
7
+ * Reads from multiple streams, one after the other.
8
+ *
9
+ * This is a read-only stream decorator.
10
+ */
11
+ class AppendStream implements StreamInterface
12
+ {
13
+ /** @var StreamInterface[] Streams being decorated */
14
+ private $streams = [];
15
+
16
+ private $seekable = true;
17
+ private $current = 0;
18
+ private $pos = 0;
19
+ private $detached = false;
20
+
21
+ /**
22
+ * @param StreamInterface[] $streams Streams to decorate. Each stream must
23
+ * be readable.
24
+ */
25
+ public function __construct(array $streams = [])
26
+ {
27
+ foreach ($streams as $stream) {
28
+ $this->addStream($stream);
29
+ }
30
+ }
31
+
32
+ public function __toString()
33
+ {
34
+ try {
35
+ $this->rewind();
36
+ return $this->getContents();
37
+ } catch (\Exception $e) {
38
+ return '';
39
+ }
40
+ }
41
+
42
+ /**
43
+ * Add a stream to the AppendStream
44
+ *
45
+ * @param StreamInterface $stream Stream to append. Must be readable.
46
+ *
47
+ * @throws \InvalidArgumentException if the stream is not readable
48
+ */
49
+ public function addStream(StreamInterface $stream)
50
+ {
51
+ if (!$stream->isReadable()) {
52
+ throw new \InvalidArgumentException('Each stream must be readable');
53
+ }
54
+
55
+ // The stream is only seekable if all streams are seekable
56
+ if (!$stream->isSeekable()) {
57
+ $this->seekable = false;
58
+ }
59
+
60
+ $this->streams[] = $stream;
61
+ }
62
+
63
+ public function getContents()
64
+ {
65
+ return copy_to_string($this);
66
+ }
67
+
68
+ /**
69
+ * Closes each attached stream.
70
+ *
71
+ * {@inheritdoc}
72
+ */
73
+ public function close()
74
+ {
75
+ $this->pos = $this->current = 0;
76
+
77
+ foreach ($this->streams as $stream) {
78
+ $stream->close();
79
+ }
80
+
81
+ $this->streams = [];
82
+ }
83
+
84
+ /**
85
+ * Detaches each attached stream
86
+ *
87
+ * {@inheritdoc}
88
+ */
89
+ public function detach()
90
+ {
91
+ $this->close();
92
+ $this->detached = true;
93
+ }
94
+
95
+ public function tell()
96
+ {
97
+ return $this->pos;
98
+ }
99
+
100
+ /**
101
+ * Tries to calculate the size by adding the size of each stream.
102
+ *
103
+ * If any of the streams do not return a valid number, then the size of the
104
+ * append stream cannot be determined and null is returned.
105
+ *
106
+ * {@inheritdoc}
107
+ */
108
+ public function getSize()
109
+ {
110
+ $size = 0;
111
+
112
+ foreach ($this->streams as $stream) {
113
+ $s = $stream->getSize();
114
+ if ($s === null) {
115
+ return null;
116
+ }
117
+ $size += $s;
118
+ }
119
+
120
+ return $size;
121
+ }
122
+
123
+ public function eof()
124
+ {
125
+ return !$this->streams ||
126
+ ($this->current >= count($this->streams) - 1 &&
127
+ $this->streams[$this->current]->eof());
128
+ }
129
+
130
+ public function rewind()
131
+ {
132
+ $this->seek(0);
133
+ }
134
+
135
+ /**
136
+ * Attempts to seek to the given position. Only supports SEEK_SET.
137
+ *
138
+ * {@inheritdoc}
139
+ */
140
+ public function seek($offset, $whence = SEEK_SET)
141
+ {
142
+ if (!$this->seekable) {
143
+ throw new \RuntimeException('This AppendStream is not seekable');
144
+ } elseif ($whence !== SEEK_SET) {
145
+ throw new \RuntimeException('The AppendStream can only seek with SEEK_SET');
146
+ }
147
+
148
+ $this->pos = $this->current = 0;
149
+
150
+ // Rewind each stream
151
+ foreach ($this->streams as $i => $stream) {
152
+ try {
153
+ $stream->rewind();
154
+ } catch (\Exception $e) {
155
+ throw new \RuntimeException('Unable to seek stream '
156
+ . $i . ' of the AppendStream', 0, $e);
157
+ }
158
+ }
159
+
160
+ // Seek to the actual position by reading from each stream
161
+ while ($this->pos < $offset && !$this->eof()) {
162
+ $result = $this->read(min(8096, $offset - $this->pos));
163
+ if ($result === '') {
164
+ break;
165
+ }
166
+ }
167
+ }
168
+
169
+ /**
170
+ * Reads from all of the appended streams until the length is met or EOF.
171
+ *
172
+ * {@inheritdoc}
173
+ */
174
+ public function read($length)
175
+ {
176
+ $buffer = '';
177
+ $total = count($this->streams) - 1;
178
+ $remaining = $length;
179
+ $progressToNext = false;
180
+
181
+ while ($remaining > 0) {
182
+
183
+ // Progress to the next stream if needed.
184
+ if ($progressToNext || $this->streams[$this->current]->eof()) {
185
+ $progressToNext = false;
186
+ if ($this->current === $total) {
187
+ break;
188
+ }
189
+ $this->current++;
190
+ }
191
+
192
+ $result = $this->streams[$this->current]->read($remaining);
193
+
194
+ // Using a loose comparison here to match on '', false, and null
195
+ if ($result == null) {
196
+ $progressToNext = true;
197
+ continue;
198
+ }
199
+
200
+ $buffer .= $result;
201
+ $remaining = $length - strlen($buffer);
202
+ }
203
+
204
+ $this->pos += strlen($buffer);
205
+
206
+ return $buffer;
207
+ }
208
+
209
+ public function isReadable()
210
+ {
211
+ return true;
212
+ }
213
+
214
+ public function isWritable()
215
+ {
216
+ return false;
217
+ }
218
+
219
+ public function isSeekable()
220
+ {
221
+ return $this->seekable;
222
+ }
223
+
224
+ public function write($string)
225
+ {
226
+ throw new \RuntimeException('Cannot write to an AppendStream');
227
+ }
228
+
229
+ public function getMetadata($key = null)
230
+ {
231
+ return $key ? null : [];
232
+ }
233
+ }
app/api/Ctct/vendor/guzzlehttp/psr7/src/BufferStream.php ADDED
@@ -0,0 +1,137 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Psr7;
3
+
4
+ use Psr\Http\Message\StreamInterface;
5
+
6
+ /**
7
+ * Provides a buffer stream that can be written to to fill a buffer, and read
8
+ * from to remove bytes from the buffer.
9
+ *
10
+ * This stream returns a "hwm" metadata value that tells upstream consumers
11
+ * what the configured high water mark of the stream is, or the maximum
12
+ * preferred size of the buffer.
13
+ */
14
+ class BufferStream implements StreamInterface
15
+ {
16
+ private $hwm;
17
+ private $buffer = '';
18
+
19
+ /**
20
+ * @param int $hwm High water mark, representing the preferred maximum
21
+ * buffer size. If the size of the buffer exceeds the high
22
+ * water mark, then calls to write will continue to succeed
23
+ * but will return false to inform writers to slow down
24
+ * until the buffer has been drained by reading from it.
25
+ */
26
+ public function __construct($hwm = 16384)
27
+ {
28
+ $this->hwm = $hwm;
29
+ }
30
+
31
+ public function __toString()
32
+ {
33
+ return $this->getContents();
34
+ }
35
+
36
+ public function getContents()
37
+ {
38
+ $buffer = $this->buffer;
39
+ $this->buffer = '';
40
+
41
+ return $buffer;
42
+ }
43
+
44
+ public function close()
45
+ {
46
+ $this->buffer = '';
47
+ }
48
+
49
+ public function detach()
50
+ {
51
+ $this->close();
52
+ }
53
+
54
+ public function getSize()
55
+ {
56
+ return strlen($this->buffer);
57
+ }
58
+
59
+ public function isReadable()
60
+ {
61
+ return true;
62
+ }
63
+
64
+ public function isWritable()
65
+ {
66
+ return true;
67
+ }
68
+
69
+ public function isSeekable()
70
+ {
71
+ return false;
72
+ }
73
+
74
+ public function rewind()
75
+ {
76
+ $this->seek(0);
77
+ }
78
+
79
+ public function seek($offset, $whence = SEEK_SET)
80
+ {
81
+ throw new \RuntimeException('Cannot seek a BufferStream');
82
+ }
83
+
84
+ public function eof()
85
+ {
86
+ return strlen($this->buffer) === 0;
87
+ }
88
+
89
+ public function tell()
90
+ {
91
+ throw new \RuntimeException('Cannot determine the position of a BufferStream');
92
+ }
93
+
94
+ /**
95
+ * Reads data from the buffer.
96
+ */
97
+ public function read($length)
98
+ {
99
+ $currentLength = strlen($this->buffer);
100
+
101
+ if ($length >= $currentLength) {
102
+ // No need to slice the buffer because we don't have enough data.
103
+ $result = $this->buffer;
104
+ $this->buffer = '';
105
+ } else {
106
+ // Slice up the result to provide a subset of the buffer.
107
+ $result = substr($this->buffer, 0, $length);
108
+ $this->buffer = substr($this->buffer, $length);
109
+ }
110
+
111
+ return $result;
112
+ }
113
+
114
+ /**
115
+ * Writes data to the buffer.
116
+ */
117
+ public function write($string)
118
+ {
119
+ $this->buffer .= $string;
120
+
121
+ // TODO: What should happen here?
122
+ if (strlen($this->buffer) >= $this->hwm) {
123
+ return false;
124
+ }
125
+
126
+ return strlen($string);
127
+ }
128
+
129
+ public function getMetadata($key = null)
130
+ {
131
+ if ($key == 'hwm') {
132
+ return $this->hwm;
133
+ }
134
+
135
+ return $key ? null : [];
136
+ }
137
+ }
app/api/Ctct/vendor/guzzlehttp/psr7/src/CachingStream.php ADDED
@@ -0,0 +1,135 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Psr7;
3
+
4
+ use Psr\Http\Message\StreamInterface;
5
+
6
+ /**
7
+ * Stream decorator that can cache previously read bytes from a sequentially
8
+ * read stream.
9
+ */
10
+ class CachingStream implements StreamInterface
11
+ {
12
+ use StreamDecoratorTrait;
13
+
14
+ /** @var StreamInterface Stream being wrapped */
15
+ private $remoteStream;
16
+
17
+ /** @var int Number of bytes to skip reading due to a write on the buffer */
18
+ private $skipReadBytes = 0;
19
+
20
+ /**
21
+ * We will treat the buffer object as the body of the stream
22
+ *
23
+ * @param StreamInterface $stream Stream to cache
24
+ * @param StreamInterface $target Optionally specify where data is cached
25
+ */
26
+ public function __construct(
27
+ StreamInterface $stream,
28
+ StreamInterface $target = null
29
+ ) {
30
+ $this->remoteStream = $stream;
31
+ $this->stream = $target ?: new Stream(fopen('php://temp', 'r+'));
32
+ }
33
+
34
+ public function getSize()
35
+ {
36
+ return max($this->stream->getSize(), $this->remoteStream->getSize());
37
+ }
38
+
39
+ public function rewind()
40
+ {
41
+ $this->seek(0);
42
+ }
43
+
44
+ public function seek($offset, $whence = SEEK_SET)
45
+ {
46
+ if ($whence == SEEK_SET) {
47
+ $byte = $offset;
48
+ } elseif ($whence == SEEK_CUR) {
49
+ $byte = $offset + $this->tell();
50
+ } elseif ($whence == SEEK_END) {
51
+ $size = $this->remoteStream->getSize();
52
+ if ($size === null) {
53
+ $size = $this->cacheEntireStream();
54
+ }
55
+ $byte = $size + $offset;
56
+ } else {
57
+ throw new \InvalidArgumentException('Invalid whence');
58
+ }
59
+
60
+ $diff = $byte - $this->stream->getSize();
61
+
62
+ if ($diff > 0) {
63
+ // If the seek byte is greater the number of read bytes, then read
64
+ // the difference of bytes to cache the bytes and inherently seek.
65
+ $this->read($diff);
66
+ } else {
67
+ // We can just do a normal seek since we've already seen this byte.
68
+ $this->stream->seek($byte);
69
+ }
70
+ }
71
+
72
+ public function read($length)
73
+ {
74
+ // Perform a regular read on any previously read data from the buffer
75
+ $data = $this->stream->read($length);
76
+ $remaining = $length - strlen($data);
77
+
78
+ // More data was requested so read from the remote stream
79
+ if ($remaining) {
80
+ // If data was written to the buffer in a position that would have
81
+ // been filled from the remote stream, then we must skip bytes on
82
+ // the remote stream to emulate overwriting bytes from that
83
+ // position. This mimics the behavior of other PHP stream wrappers.
84
+ $remoteData = $this->remoteStream->read(
85
+ $remaining + $this->skipReadBytes
86
+ );
87
+
88
+ if ($this->skipReadBytes) {
89
+ $len = strlen($remoteData);
90
+ $remoteData = substr($remoteData, $this->skipReadBytes);
91
+ $this->skipReadBytes = max(0, $this->skipReadBytes - $len);
92
+ }
93
+
94
+ $data .= $remoteData;
95
+ $this->stream->write($remoteData);
96
+ }
97
+
98
+ return $data;
99
+ }
100
+
101
+ public function write($string)
102
+ {
103
+ // When appending to the end of the currently read stream, you'll want
104
+ // to skip bytes from being read from the remote stream to emulate
105
+ // other stream wrappers. Basically replacing bytes of data of a fixed
106
+ // length.
107
+ $overflow = (strlen($string) + $this->tell()) - $this->remoteStream->tell();
108
+ if ($overflow > 0) {
109
+ $this->skipReadBytes += $overflow;
110
+ }
111
+
112
+ return $this->stream->write($string);
113
+ }
114
+
115
+ public function eof()
116
+ {
117
+ return $this->stream->eof() && $this->remoteStream->eof();
118
+ }
119
+
120
+ /**
121
+ * Close both the remote stream and buffer stream
122
+ */
123
+ public function close()
124
+ {
125
+ $this->remoteStream->close() && $this->stream->close();
126
+ }
127
+
128
+ private function cacheEntireStream()
129
+ {
130
+ $target = new FnStream(['write' => 'strlen']);
131
+ copy_to_stream($this, $target);
132
+
133
+ return $this->tell();
134
+ }
135
+ }
app/api/Ctct/vendor/guzzlehttp/psr7/src/DroppingStream.php ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Psr7;
3
+
4
+ use Psr\Http\Message\StreamInterface;
5
+
6
+ /**
7
+ * Stream decorator that begins dropping data once the size of the underlying
8
+ * stream becomes too full.
9
+ */
10
+ class DroppingStream implements StreamInterface
11
+ {
12
+ use StreamDecoratorTrait;
13
+
14
+ private $maxLength;
15
+
16
+ /**
17
+ * @param StreamInterface $stream Underlying stream to decorate.
18
+ * @param int $maxLength Maximum size before dropping data.
19
+ */
20
+ public function __construct(StreamInterface $stream, $maxLength)
21
+ {
22
+ $this->stream = $stream;
23
+ $this->maxLength = $maxLength;
24
+ }
25
+
26
+ public function write($string)
27
+ {
28
+ $diff = $this->maxLength - $this->stream->getSize();
29
+
30
+ // Begin returning 0 when the underlying stream is too large.
31
+ if ($diff <= 0) {
32
+ return 0;
33
+ }
34
+
35
+ // Write the stream or a subset of the stream if needed.
36
+ if (strlen($string) < $diff) {
37
+ return $this->stream->write($string);
38
+ }
39
+
40
+ return $this->stream->write(substr($string, 0, $diff));
41
+ }
42
+ }
app/api/Ctct/vendor/guzzlehttp/psr7/src/FnStream.php ADDED
@@ -0,0 +1,149 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Psr7;
3
+
4
+ use Psr\Http\Message\StreamInterface;
5
+
6
+ /**
7
+ * Compose stream implementations based on a hash of functions.
8
+ *
9
+ * Allows for easy testing and extension of a provided stream without needing
10
+ * to create a concrete class for a simple extension point.
11
+ */
12
+ class FnStream implements StreamInterface
13
+ {
14
+ /** @var array */
15
+ private $methods;
16
+
17
+ /** @var array Methods that must be implemented in the given array */
18
+ private static $slots = ['__toString', 'close', 'detach', 'rewind',
19
+ 'getSize', 'tell', 'eof', 'isSeekable', 'seek', 'isWritable', 'write',
20
+ 'isReadable', 'read', 'getContents', 'getMetadata'];
21
+
22
+ /**
23
+ * @param array $methods Hash of method name to a callable.
24
+ */
25
+ public function __construct(array $methods)
26
+ {
27
+ $this->methods = $methods;
28
+
29
+ // Create the functions on the class
30
+ foreach ($methods as $name => $fn) {
31
+ $this->{'_fn_' . $name} = $fn;
32
+ }
33
+ }
34
+
35
+ /**
36
+ * Lazily determine which methods are not implemented.
37
+ * @throws \BadMethodCallException
38
+ */
39
+ public function __get($name)
40
+ {
41
+ throw new \BadMethodCallException(str_replace('_fn_', '', $name)
42
+ . '() is not implemented in the FnStream');
43
+ }
44
+
45
+ /**
46
+ * The close method is called on the underlying stream only if possible.
47
+ */
48
+ public function __destruct()
49
+ {
50
+ if (isset($this->_fn_close)) {
51
+ call_user_func($this->_fn_close);
52
+ }
53
+ }
54
+
55
+ /**
56
+ * Adds custom functionality to an underlying stream by intercepting
57
+ * specific method calls.
58
+ *
59
+ * @param StreamInterface $stream Stream to decorate
60
+ * @param array $methods Hash of method name to a closure
61
+ *
62
+ * @return FnStream
63
+ */
64
+ public static function decorate(StreamInterface $stream, array $methods)
65
+ {
66
+ // If any of the required methods were not provided, then simply
67
+ // proxy to the decorated stream.
68
+ foreach (array_diff(self::$slots, array_keys($methods)) as $diff) {
69
+ $methods[$diff] = [$stream, $diff];
70
+ }
71
+
72
+ return new self($methods);
73
+ }
74
+
75
+ public function __toString()
76
+ {
77
+ return call_user_func($this->_fn___toString);
78
+ }
79
+
80
+ public function close()
81
+ {
82
+ return call_user_func($this->_fn_close);
83
+ }
84
+
85
+ public function detach()
86
+ {
87
+ return call_user_func($this->_fn_detach);
88
+ }
89
+
90
+ public function getSize()
91
+ {
92
+ return call_user_func($this->_fn_getSize);
93
+ }
94
+
95
+ public function tell()
96
+ {
97
+ return call_user_func($this->_fn_tell);
98
+ }
99
+
100
+ public function eof()
101
+ {
102
+ return call_user_func($this->_fn_eof);
103
+ }
104
+
105
+ public function isSeekable()
106
+ {
107
+ return call_user_func($this->_fn_isSeekable);
108
+ }
109
+
110
+ public function rewind()
111
+ {
112
+ call_user_func($this->_fn_rewind);
113
+ }
114
+
115
+ public function seek($offset, $whence = SEEK_SET)
116
+ {
117
+ call_user_func($this->_fn_seek, $offset, $whence);
118
+ }
119
+
120
+ public function isWritable()
121
+ {
122
+ return call_user_func($this->_fn_isWritable);
123
+ }
124
+
125
+ public function write($string)
126
+ {
127
+ return call_user_func($this->_fn_write, $string);
128
+ }
129
+
130
+ public function isReadable()
131
+ {
132
+ return call_user_func($this->_fn_isReadable);
133
+ }
134
+
135
+ public function read($length)
136
+ {
137
+ return call_user_func($this->_fn_read, $length);
138
+ }
139
+
140
+ public function getContents()
141
+ {
142
+ return call_user_func($this->_fn_getContents);
143
+ }
144
+
145
+ public function getMetadata($key = null)
146
+ {
147
+ return call_user_func($this->_fn_getMetadata, $key);
148
+ }
149
+ }
app/api/Ctct/vendor/guzzlehttp/psr7/src/InflateStream.php ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Psr7;
3
+
4
+ use Psr\Http\Message\StreamInterface;
5
+
6
+ /**
7
+ * Uses PHP's zlib.inflate filter to inflate deflate or gzipped content.
8
+ *
9
+ * This stream decorator skips the first 10 bytes of the given stream to remove
10
+ * the gzip header, converts the provided stream to a PHP stream resource,
11
+ * then appends the zlib.inflate filter. The stream is then converted back
12
+ * to a Guzzle stream resource to be used as a Guzzle stream.
13
+ *
14
+ * @link http://tools.ietf.org/html/rfc1952
15
+ * @link http://php.net/manual/en/filters.compression.php
16
+ */
17
+ class InflateStream implements StreamInterface
18
+ {
19
+ use StreamDecoratorTrait;
20
+
21
+ public function __construct(StreamInterface $stream)
22
+ {
23
+ // Skip the first 10 bytes
24
+ $stream = new LimitStream($stream, -1, 10);
25
+ $resource = StreamWrapper::getResource($stream);
26
+ stream_filter_append($resource, 'zlib.inflate', STREAM_FILTER_READ);
27
+ $this->stream = new Stream($resource);
28
+ }
29
+ }
app/api/Ctct/vendor/guzzlehttp/psr7/src/LazyOpenStream.php ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Psr7;
3
+
4
+ use Psr\Http\Message\StreamInterface;
5
+
6
+ /**
7
+ * Lazily reads or writes to a file that is opened only after an IO operation
8
+ * take place on the stream.
9
+ */
10
+ class LazyOpenStream implements StreamInterface
11
+ {
12
+ use StreamDecoratorTrait;
13
+
14
+ /** @var string File to open */
15
+ private $filename;
16
+
17
+ /** @var string $mode */
18
+ private $mode;
19
+
20
+ /**
21
+ * @param string $filename File to lazily open
22
+ * @param string $mode fopen mode to use when opening the stream
23
+ */
24
+ public function __construct($filename, $mode)
25
+ {
26
+ $this->filename = $filename;
27
+ $this->mode = $mode;
28
+ }
29
+
30
+ /**
31
+ * Creates the underlying stream lazily when required.
32
+ *
33
+ * @return StreamInterface
34
+ */
35
+ protected function createStream()
36
+ {
37
+ return stream_for(try_fopen($this->filename, $this->mode));
38
+ }
39
+ }
app/api/Ctct/vendor/guzzlehttp/psr7/src/LimitStream.php ADDED
@@ -0,0 +1,155 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Psr7;
3
+
4
+ use Psr\Http\Message\StreamInterface;
5
+
6
+
7
+ /**
8
+ * Decorator used to return only a subset of a stream
9
+ */
10
+ class LimitStream implements StreamInterface
11
+ {
12
+ use StreamDecoratorTrait;
13
+
14
+ /** @var int Offset to start reading from */
15
+ private $offset;
16
+
17
+ /** @var int Limit the number of bytes that can be read */
18
+ private $limit;
19
+
20
+ /**
21
+ * @param StreamInterface $stream Stream to wrap
22
+ * @param int $limit Total number of bytes to allow to be read
23
+ * from the stream. Pass -1 for no limit.
24
+ * @param int|null $offset Position to seek to before reading (only
25
+ * works on seekable streams).
26
+ */
27
+ public function __construct(
28
+ StreamInterface $stream,
29
+ $limit = -1,
30
+ $offset = 0
31
+ ) {
32
+ $this->stream = $stream;
33
+ $this->setLimit($limit);
34
+ $this->setOffset($offset);
35
+ }
36
+
37
+ public function eof()
38
+ {
39
+ // Always return true if the underlying stream is EOF
40
+ if ($this->stream->eof()) {
41
+ return true;
42
+ }
43
+
44
+ // No limit and the underlying stream is not at EOF
45
+ if ($this->limit == -1) {
46
+ return false;
47
+ }
48
+
49
+ return $this->stream->tell() >= $this->offset + $this->limit;
50
+ }
51
+
52
+ /**
53
+ * Returns the size of the limited subset of data
54
+ * {@inheritdoc}
55
+ */
56
+ public function getSize()
57
+ {
58
+ if (null === ($length = $this->stream->getSize())) {
59
+ return null;
60
+ } elseif ($this->limit == -1) {
61
+ return $length - $this->offset;
62
+ } else {
63
+ return min($this->limit, $length - $this->offset);
64
+ }
65
+ }
66
+
67
+ /**
68
+ * Allow for a bounded seek on the read limited stream
69
+ * {@inheritdoc}
70
+ */
71
+ public function seek($offset, $whence = SEEK_SET)
72
+ {
73
+ if ($whence !== SEEK_SET || $offset < 0) {
74
+ throw new \RuntimeException(sprintf(
75
+ 'Cannot seek to offset % with whence %s',
76
+ $offset,
77
+ $whence
78
+ ));
79
+ }
80
+
81
+ $offset += $this->offset;
82
+
83
+ if ($this->limit !== -1) {
84
+ if ($offset > $this->offset + $this->limit) {
85
+ $offset = $this->offset + $this->limit;
86
+ }
87
+ }
88
+
89
+ $this->stream->seek($offset);
90
+ }
91
+
92
+ /**
93
+ * Give a relative tell()
94
+ * {@inheritdoc}
95
+ */
96
+ public function tell()
97
+ {
98
+ return $this->stream->tell() - $this->offset;
99
+ }
100
+
101
+ /**
102
+ * Set the offset to start limiting from
103
+ *
104
+ * @param int $offset Offset to seek to and begin byte limiting from
105
+ *
106
+ * @throws \RuntimeException if the stream cannot be seeked.
107
+ */
108
+ public function setOffset($offset)
109
+ {
110
+ $current = $this->stream->tell();
111
+
112
+ if ($current !== $offset) {
113
+ // If the stream cannot seek to the offset position, then read to it
114
+ if ($this->stream->isSeekable()) {
115
+ $this->stream->seek($offset);
116
+ } elseif ($current > $offset) {
117
+ throw new \RuntimeException("Could not seek to stream offset $offset");
118
+ } else {
119
+ $this->stream->read($offset - $current);
120
+ }
121
+ }
122
+
123
+ $this->offset = $offset;
124
+ }
125
+
126
+ /**
127
+ * Set the limit of bytes that the decorator allows to be read from the
128
+ * stream.
129
+ *
130
+ * @param int $limit Number of bytes to allow to be read from the stream.
131
+ * Use -1 for no limit.
132
+ */
133
+ public function setLimit($limit)
134
+ {
135
+ $this->limit = $limit;
136
+ }
137
+
138
+ public function read($length)
139
+ {
140
+ if ($this->limit == -1) {
141
+ return $this->stream->read($length);
142
+ }
143
+
144
+ // Check if the current position is less than the total allowed
145
+ // bytes + original offset
146
+ $remaining = ($this->offset + $this->limit) - $this->stream->tell();
147
+ if ($remaining > 0) {
148
+ // Only return the amount of requested data, ensuring that the byte
149
+ // limit is not exceeded
150
+ return $this->stream->read(min($remaining, $length));
151
+ }
152
+
153
+ return '';
154
+ }
155
+ }
app/api/Ctct/vendor/guzzlehttp/psr7/src/MessageTrait.php ADDED
@@ -0,0 +1,158 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Psr7;
3
+
4
+ use Psr\Http\Message\StreamInterface;
5
+
6
+ /**
7
+ * Trait implementing functionality common to requests and responses.
8
+ */
9
+ trait MessageTrait
10
+ {
11
+ /** @var array Cached HTTP header collection with lowercase key to values */
12
+ private $headers = [];
13
+
14
+ /** @var array Actual key to list of values per header. */
15
+ private $headerLines = [];
16
+
17
+ /** @var string */
18
+ private $protocol = '1.1';
19
+
20
+ /** @var StreamInterface */
21
+ private $stream;
22
+
23
+ public function getProtocolVersion()
24
+ {
25
+ return $this->protocol;
26
+ }
27
+
28
+ public function withProtocolVersion($version)
29
+ {
30
+ if ($this->protocol === $version) {
31
+ return $this;
32
+ }
33
+
34
+ $new = clone $this;
35
+ $new->protocol = $version;
36
+ return $new;
37
+ }
38
+
39
+ public function getHeaders()
40
+ {
41
+ return $this->headerLines;
42
+ }
43
+
44
+ public function hasHeader($header)
45
+ {
46
+ return isset($this->headers[strtolower($header)]);
47
+ }
48
+
49
+ public function getHeader($header)
50
+ {
51
+ $name = strtolower($header);
52
+ return isset($this->headers[$name]) ? $this->headers[$name] : [];
53
+ }
54
+
55
+ public function getHeaderLine($header)
56
+ {
57
+ return implode(', ', $this->getHeader($header));
58
+ }
59
+
60
+ public function withHeader($header, $value)
61
+ {
62
+ $new = clone $this;
63
+ $header = trim($header);
64
+ $name = strtolower($header);
65
+
66
+ if (!is_array($value)) {
67
+ $new->headers[$name] = [trim($value)];
68
+ } else {
69
+ $new->headers[$name] = $value;
70
+ foreach ($new->headers[$name] as &$v) {
71
+ $v = trim($v);
72
+ }
73
+ }
74
+
75
+ // Remove the header lines.
76
+ foreach (array_keys($new->headerLines) as $key) {
77
+ if (strtolower($key) === $name) {
78
+ unset($new->headerLines[$key]);
79
+ }
80
+ }
81
+
82
+ // Add the header line.
83
+ $new->headerLines[$header] = $new->headers[$name];
84
+
85
+ return $new;
86
+ }
87
+
88
+ public function withAddedHeader($header, $value)
89
+ {
90
+ if (!$this->hasHeader($header)) {
91
+ return $this->withHeader($header, $value);
92
+ }
93
+
94
+ $new = clone $this;
95
+ $new->headers[strtolower($header)][] = $value;
96
+ $new->headerLines[$header][] = $value;
97
+ return $new;
98
+ }
99
+
100
+ public function withoutHeader($header)
101
+ {
102
+ if (!$this->hasHeader($header)) {
103
+ return $this;
104
+ }
105
+
106
+ $new = clone $this;
107
+ $name = strtolower($header);
108
+ unset($new->headers[$name]);
109
+
110
+ foreach (array_keys($new->headerLines) as $key) {
111
+ if (strtolower($key) === $name) {
112
+ unset($new->headerLines[$key]);
113
+ }
114
+ }
115
+
116
+ return $new;
117
+ }
118
+
119
+ public function getBody()
120
+ {
121
+ if (!$this->stream) {
122
+ $this->stream = stream_for('');
123
+ }
124
+
125
+ return $this->stream;
126
+ }
127
+
128
+ public function withBody(StreamInterface $body)
129
+ {
130
+ if ($body === $this->stream) {
131
+ return $this;
132
+ }
133
+
134
+ $new = clone $this;
135
+ $new->stream = $body;
136
+ return $new;
137
+ }
138
+
139
+ private function setHeaders(array $headers)
140
+ {
141
+ $this->headerLines = $this->headers = [];
142
+ foreach ($headers as $header => $value) {
143
+ $header = trim($header);
144
+ $name = strtolower($header);
145
+ if (!is_array($value)) {
146
+ $value = trim($value);
147
+ $this->headers[$name][] = $value;
148
+ $this->headerLines[$header][] = $value;
149
+ } else {
150
+ foreach ($value as $v) {
151
+ $v = trim($v);
152
+ $this->headers[$name][] = $v;
153
+ $this->headerLines[$header][] = $v;
154
+ }
155
+ }
156
+ }
157
+ }
158
+ }
app/api/Ctct/vendor/guzzlehttp/psr7/src/MultipartStream.php ADDED
@@ -0,0 +1,153 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Psr7;
3
+
4
+ use Psr\Http\Message\StreamInterface;
5
+
6
+ /**
7
+ * Stream that when read returns bytes for a streaming multipart or
8
+ * multipart/form-data stream.
9
+ */
10
+ class MultipartStream implements StreamInterface
11
+ {
12
+ use StreamDecoratorTrait;
13
+
14
+ private $boundary;
15
+
16
+ /**
17
+ * @param array $elements Array of associative arrays, each containing a
18
+ * required "name" key mapping to the form field,
19
+ * name, a required "contents" key mapping to a
20
+ * StreamInterface/resource/string, an optional
21
+ * "headers" associative array of custom headers,
22
+ * and an optional "filename" key mapping to a
23
+ * string to send as the filename in the part.
24
+ * @param string $boundary You can optionally provide a specific boundary
25
+ *
26
+ * @throws \InvalidArgumentException
27
+ */
28
+ public function __construct(array $elements = [], $boundary = null)
29
+ {
30
+ $this->boundary = $boundary ?: uniqid();
31
+ $this->stream = $this->createStream($elements);
32
+ }
33
+
34
+ /**
35
+ * Get the boundary
36
+ *
37
+ * @return string
38
+ */
39
+ public function getBoundary()
40
+ {
41
+ return $this->boundary;
42
+ }
43
+
44
+ public function isWritable()
45
+ {
46
+ return false;
47
+ }
48
+
49
+ /**
50
+ * Get the headers needed before transferring the content of a POST file
51
+ */
52
+ private function getHeaders(array $headers)
53
+ {
54
+ $str = '';
55
+ foreach ($headers as $key => $value) {
56
+ $str .= "{$key}: {$value}\r\n";
57
+ }
58
+
59
+ return "--{$this->boundary}\r\n" . trim($str) . "\r\n\r\n";
60
+ }
61
+
62
+ /**
63
+ * Create the aggregate stream that will be used to upload the POST data
64
+ */
65
+ protected function createStream(array $elements)
66
+ {
67
+ $stream = new AppendStream();
68
+
69
+ foreach ($elements as $element) {
70
+ $this->addElement($stream, $element);
71
+ }
72
+
73
+ // Add the trailing boundary with CRLF
74
+ $stream->addStream(stream_for("--{$this->boundary}--\r\n"));
75
+
76
+ return $stream;
77
+ }
78
+
79
+ private function addElement(AppendStream $stream, array $element)
80
+ {
81
+ foreach (['contents', 'name'] as $key) {
82
+ if (!array_key_exists($key, $element)) {
83
+ throw new \InvalidArgumentException("A '{$key}' key is required");
84
+ }
85
+ }
86
+
87
+ $element['contents'] = stream_for($element['contents']);
88
+
89
+ if (empty($element['filename'])) {
90
+ $uri = $element['contents']->getMetadata('uri');
91
+ if (substr($uri, 0, 6) !== 'php://') {
92
+ $element['filename'] = $uri;
93
+ }
94
+ }
95
+
96
+ list($body, $headers) = $this->createElement(
97
+ $element['name'],
98
+ $element['contents'],
99
+ isset($element['filename']) ? $element['filename'] : null,
100
+ isset($element['headers']) ? $element['headers'] : []
101
+ );
102
+
103
+ $stream->addStream(stream_for($this->getHeaders($headers)));
104
+ $stream->addStream($body);
105
+ $stream->addStream(stream_for("\r\n"));
106
+ }
107
+
108
+ /**
109
+ * @return array
110
+ */
111
+ private function createElement($name, $stream, $filename, array $headers)
112
+ {
113
+ // Set a default content-disposition header if one was no provided
114
+ $disposition = $this->getHeader($headers, 'content-disposition');
115
+ if (!$disposition) {
116
+ $headers['Content-Disposition'] = ($filename === '0' || $filename)
117
+ ? sprintf('form-data; name="%s"; filename="%s"',
118
+ $name,
119
+ basename($filename))
120
+ : "form-data; name=\"{$name}\"";
121
+ }
122
+
123
+ // Set a default content-length header if one was no provided
124
+ $length = $this->getHeader($headers, 'content-length');
125
+ if (!$length) {
126
+ if ($length = $stream->getSize()) {
127
+ $headers['Content-Length'] = (string) $length;
128
+ }
129
+ }
130
+
131
+ // Set a default Content-Type if one was not supplied
132
+ $type = $this->getHeader($headers, 'content-type');
133
+ if (!$type && ($filename === '0' || $filename)) {
134
+ if ($type = mimetype_from_filename($filename)) {
135
+ $headers['Content-Type'] = $type;
136
+ }
137
+ }
138
+
139
+ return [$stream, $headers];
140
+ }
141
+
142
+ private function getHeader(array $headers, $key)
143
+ {
144
+ $lowercaseHeader = strtolower($key);
145
+ foreach ($headers as $k => $v) {
146
+ if (strtolower($k) === $lowercaseHeader) {
147
+ return $v;
148
+ }
149
+ }
150
+
151
+ return null;
152
+ }
153
+ }
app/api/Ctct/vendor/guzzlehttp/psr7/src/NoSeekStream.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Psr7;
3
+
4
+ use Psr\Http\Message\StreamInterface;
5
+
6
+ /**
7
+ * Stream decorator that prevents a stream from being seeked
8
+ */
9
+ class NoSeekStream implements StreamInterface
10
+ {
11
+ use StreamDecoratorTrait;
12
+
13
+ public function seek($offset, $whence = SEEK_SET)
14
+ {
15
+ throw new \RuntimeException('Cannot seek a NoSeekStream');
16
+ }
17
+
18
+ public function isSeekable()
19
+ {
20
+ return false;
21
+ }
22
+ }
app/api/Ctct/vendor/guzzlehttp/psr7/src/PumpStream.php ADDED
@@ -0,0 +1,165 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Psr7;
3
+
4
+ use Psr\Http\Message\StreamInterface;
5
+
6
+ /**
7
+ * Provides a read only stream that pumps data from a PHP callable.
8
+ *
9
+ * When invoking the provided callable, the PumpStream will pass the amount of
10
+ * data requested to read to the callable. The callable can choose to ignore
11
+ * this value and return fewer or more bytes than requested. Any extra data
12
+ * returned by the provided callable is buffered internally until drained using
13
+ * the read() function of the PumpStream. The provided callable MUST return
14
+ * false when there is no more data to read.
15
+ */
16
+ class PumpStream implements StreamInterface
17
+ {
18
+ /** @var callable */
19
+ private $source;
20
+
21
+ /** @var int */
22
+ private $size;
23
+
24
+ /** @var int */
25
+ private $tellPos = 0;
26
+
27
+ /** @var array */
28
+ private $metadata;
29
+
30
+ /** @var BufferStream */
31
+ private $buffer;
32
+
33
+ /**
34
+ * @param callable $source Source of the stream data. The callable MAY
35
+ * accept an integer argument used to control the
36
+ * amount of data to return. The callable MUST
37
+ * return a string when called, or false on error
38
+ * or EOF.
39
+ * @param array $options Stream options:
40
+ * - metadata: Hash of metadata to use with stream.
41
+ * - size: Size of the stream, if known.
42
+ */
43
+ public function __construct(callable $source, array $options = [])
44
+ {
45
+ $this->source = $source;
46
+ $this->size = isset($options['size']) ? $options['size'] : null;
47
+ $this->metadata = isset($options['metadata']) ? $options['metadata'] : [];
48
+ $this->buffer = new BufferStream();
49
+ }
50
+
51
+ public function __toString()
52
+ {
53
+ try {
54
+ return copy_to_string($this);
55
+ } catch (\Exception $e) {
56
+ return '';
57
+ }
58
+ }
59
+
60
+ public function close()
61
+ {
62
+ $this->detach();
63
+ }
64
+
65
+ public function detach()
66
+ {
67
+ $this->tellPos = false;
68
+ $this->source = null;
69
+ }
70
+
71
+ public function getSize()
72
+ {
73
+ return $this->size;
74
+ }
75
+
76
+ public function tell()
77
+ {
78
+ return $this->tellPos;
79
+ }
80
+
81
+ public function eof()
82
+ {
83
+ return !$this->source;
84
+ }
85
+
86
+ public function isSeekable()
87
+ {
88
+ return false;
89
+ }
90
+
91
+ public function rewind()
92
+ {
93
+ $this->seek(0);
94
+ }
95
+
96
+ public function seek($offset, $whence = SEEK_SET)
97
+ {
98
+ throw new \RuntimeException('Cannot seek a PumpStream');
99
+ }
100
+
101
+ public function isWritable()
102
+ {
103
+ return false;
104
+ }
105
+
106
+ public function write($string)
107
+ {
108
+ throw new \RuntimeException('Cannot write to a PumpStream');
109
+ }
110
+
111
+ public function isReadable()
112
+ {
113
+ return true;
114
+ }
115
+
116
+ public function read($length)
117
+ {
118
+ $data = $this->buffer->read($length);
119
+ $readLen = strlen($data);
120
+ $this->tellPos += $readLen;
121
+ $remaining = $length - $readLen;
122
+
123
+ if ($remaining) {
124
+ $this->pump($remaining);
125
+ $data .= $this->buffer->read($remaining);
126
+ $this->tellPos += strlen($data) - $readLen;
127
+ }
128
+
129
+ return $data;
130
+ }
131
+
132
+ public function getContents()
133
+ {
134
+ $result = '';
135
+ while (!$this->eof()) {
136
+ $result .= $this->read(1000000);
137
+ }
138
+
139
+ return $result;
140
+ }
141
+
142
+ public function getMetadata($key = null)
143
+ {
144
+ if (!$key) {
145
+ return $this->metadata;
146
+ }
147
+
148
+ return isset($this->metadata[$key]) ? $this->metadata[$key] : null;
149
+ }
150
+
151
+ private function pump($length)
152
+ {
153
+ if ($this->source) {
154
+ do {
155
+ $data = call_user_func($this->source, $length);
156
+ if ($data === false || $data === null) {
157
+ $this->source = null;
158
+ return;
159
+ }
160
+ $this->buffer->write($data);
161
+ $length -= strlen($data);
162
+ } while ($length > 0);
163
+ }
164
+ }
165
+ }
app/api/Ctct/vendor/guzzlehttp/psr7/src/Request.php ADDED
@@ -0,0 +1,149 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Psr7;
3
+
4
+ use InvalidArgumentException;
5
+ use Psr\Http\Message\RequestInterface;
6
+ use Psr\Http\Message\StreamInterface;
7
+ use Psr\Http\Message\UriInterface;
8
+
9
+ /**
10
+ * PSR-7 request implementation.
11
+ */
12
+ class Request implements RequestInterface
13
+ {
14
+ use MessageTrait {
15
+ withHeader as protected withParentHeader;
16
+ }
17
+
18
+ /** @var string */
19
+ private $method;
20
+
21
+ /** @var null|string */
22
+ private $requestTarget;
23
+
24
+ /** @var null|UriInterface */
25
+ private $uri;
26
+
27
+ /**
28
+ * @param null|string $method HTTP method for the request.
29
+ * @param null|string|UriInterface $uri URI for the request.
30
+ * @param array $headers Headers for the message.
31
+ * @param string|resource|StreamInterface $body Message body.
32
+ * @param string $protocolVersion HTTP protocol version.
33
+ *
34
+ * @throws InvalidArgumentException for an invalid URI
35
+ */
36
+ public function __construct(
37
+ $method,
38
+ $uri,
39
+ array $headers = [],
40
+ $body = null,
41
+ $protocolVersion = '1.1'
42
+ ) {
43
+ if (is_string($uri)) {
44
+ $uri = new Uri($uri);
45
+ } elseif (!($uri instanceof UriInterface)) {
46
+ throw new \InvalidArgumentException(
47
+ 'URI must be a string or Psr\Http\Message\UriInterface'
48
+ );
49
+ }
50
+
51
+ $this->method = strtoupper($method);
52
+ $this->uri = $uri;
53
+ $this->setHeaders($headers);
54
+ $this->protocol = $protocolVersion;
55
+
56
+ $host = $uri->getHost();
57
+ if ($host && !$this->hasHeader('Host')) {
58
+ $this->updateHostFromUri($host);
59
+ }
60
+
61
+ if ($body) {
62
+ $this->stream = stream_for($body);
63
+ }
64
+ }
65
+
66
+ public function getRequestTarget()
67
+ {
68
+ if ($this->requestTarget !== null) {
69
+ return $this->requestTarget;
70
+ }
71
+
72
+ $target = $this->uri->getPath();
73
+ if ($target == null) {
74
+ $target = '/';
75
+ }
76
+ if ($this->uri->getQuery()) {
77
+ $target .= '?' . $this->uri->getQuery();
78
+ }
79
+
80
+ return $target;
81
+ }
82
+
83
+ public function withRequestTarget($requestTarget)
84
+ {
85
+ if (preg_match('#\s#', $requestTarget)) {
86
+ throw new InvalidArgumentException(
87
+ 'Invalid request target provided; cannot contain whitespace'
88
+ );
89
+ }
90
+
91
+ $new = clone $this;
92
+ $new->requestTarget = $requestTarget;
93
+ return $new;
94
+ }
95
+
96
+ public function getMethod()
97
+ {
98
+ return $this->method;
99
+ }
100
+
101
+ public function withMethod($method)
102
+ {
103
+ $new = clone $this;
104
+ $new->method = strtoupper($method);
105
+ return $new;
106
+ }
107
+
108
+ public function getUri()
109
+ {
110
+ return $this->uri;
111
+ }
112
+
113
+ public function withUri(UriInterface $uri, $preserveHost = false)
114
+ {
115
+ if ($uri === $this->uri) {
116
+ return $this;
117
+ }
118
+
119
+ $new = clone $this;
120
+ $new->uri = $uri;
121
+
122
+ if (!$preserveHost) {
123
+ if ($host = $uri->getHost()) {
124
+ $new->updateHostFromUri($host);
125
+ }
126
+ }
127
+
128
+ return $new;
129
+ }
130
+
131
+ public function withHeader($header, $value)
132
+ {
133
+ /** @var Request $newInstance */
134
+ $newInstance = $this->withParentHeader($header, $value);
135
+ return $newInstance;
136
+ }
137
+
138
+ private function updateHostFromUri($host)
139
+ {
140
+ // Ensure Host is the first header.
141
+ // See: http://tools.ietf.org/html/rfc7230#section-5.4
142
+ if ($port = $this->uri->getPort()) {
143
+ $host .= ':' . $port;
144
+ }
145
+
146
+ $this->headerLines = ['Host' => [$host]] + $this->headerLines;
147
+ $this->headers = ['host' => [$host]] + $this->headers;
148
+ }
149
+ }
app/api/Ctct/vendor/guzzlehttp/psr7/src/Response.php ADDED
@@ -0,0 +1,131 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Psr7;
3
+
4
+ use Psr\Http\Message\ResponseInterface;
5
+
6
+ /**
7
+ * PSR-7 response implementation.
8
+ */
9
+ class Response implements ResponseInterface
10
+ {
11
+ use MessageTrait;
12
+
13
+ /** @var array Map of standard HTTP status code/reason phrases */
14
+ private static $phrases = [
15
+ 100 => 'Continue',
16
+ 101 => 'Switching Protocols',
17
+ 102 => 'Processing',
18
+ 200 => 'OK',
19
+ 201 => 'Created',
20
+ 202 => 'Accepted',
21
+ 203 => 'Non-Authoritative Information',
22
+ 204 => 'No Content',
23
+ 205 => 'Reset Content',
24
+ 206 => 'Partial Content',
25
+ 207 => 'Multi-status',
26
+ 208 => 'Already Reported',
27
+ 300 => 'Multiple Choices',
28
+ 301 => 'Moved Permanently',
29
+ 302 => 'Found',
30
+ 303 => 'See Other',
31
+ 304 => 'Not Modified',
32
+ 305 => 'Use Proxy',
33
+ 306 => 'Switch Proxy',
34
+ 307 => 'Temporary Redirect',
35
+ 400 => 'Bad Request',
36
+ 401 => 'Unauthorized',
37
+ 402 => 'Payment Required',
38
+ 403 => 'Forbidden',
39
+ 404 => 'Not Found',
40
+ 405 => 'Method Not Allowed',
41
+ 406 => 'Not Acceptable',
42
+ 407 => 'Proxy Authentication Required',
43
+ 408 => 'Request Time-out',
44
+ 409 => 'Conflict',
45
+ 410 => 'Gone',
46
+ 411 => 'Length Required',
47
+ 412 => 'Precondition Failed',
48
+ 413 => 'Request Entity Too Large',
49
+ 414 => 'Request-URI Too Large',
50
+ 415 => 'Unsupported Media Type',
51
+ 416 => 'Requested range not satisfiable',
52
+ 417 => 'Expectation Failed',
53
+ 418 => 'I\'m a teapot',
54
+ 422 => 'Unprocessable Entity',
55
+ 423 => 'Locked',
56
+ 424 => 'Failed Dependency',
57
+ 425 => 'Unordered Collection',
58
+ 426 => 'Upgrade Required',
59
+ 428 => 'Precondition Required',
60
+ 429 => 'Too Many Requests',
61
+ 431 => 'Request Header Fields Too Large',
62
+ 451 => 'Unavailable For Legal Reasons',
63
+ 500 => 'Internal Server Error',
64
+ 501 => 'Not Implemented',
65
+ 502 => 'Bad Gateway',
66
+ 503 => 'Service Unavailable',
67
+ 504 => 'Gateway Time-out',
68
+ 505 => 'HTTP Version not supported',
69
+ 506 => 'Variant Also Negotiates',
70
+ 507 => 'Insufficient Storage',
71
+ 508 => 'Loop Detected',
72
+ 511 => 'Network Authentication Required',
73
+ ];
74
+
75
+ /** @var null|string */
76
+ private $reasonPhrase = '';
77
+
78
+ /** @var int */
79
+ private $statusCode = 200;
80
+
81
+ /**
82
+ * @param int $status Status code for the response, if any.
83
+ * @param array $headers Headers for the response, if any.
84
+ * @param mixed $body Stream body.
85
+ * @param string $version Protocol version.
86
+ * @param string $reason Reason phrase (a default will be used if possible).
87
+ */
88
+ public function __construct(
89
+ $status = 200,
90
+ array $headers = [],
91
+ $body = null,
92
+ $version = '1.1',
93
+ $reason = null
94
+ ) {
95
+ $this->statusCode = (int) $status;
96
+
97
+ if ($body !== null) {
98
+ $this->stream = stream_for($body);
99
+ }
100
+
101
+ $this->setHeaders($headers);
102
+ if (!$reason && isset(self::$phrases[$this->statusCode])) {
103
+ $this->reasonPhrase = self::$phrases[$status];
104
+ } else {
105
+ $this->reasonPhrase = (string) $reason;
106
+ }
107
+
108
+ $this->protocol = $version;
109
+ }
110
+
111
+ public function getStatusCode()
112
+ {
113
+ return $this->statusCode;
114
+ }
115
+
116
+ public function getReasonPhrase()
117
+ {
118
+ return $this->reasonPhrase;
119
+ }
120
+
121
+ public function withStatus($code, $reasonPhrase = '')
122
+ {
123
+ $new = clone $this;
124
+ $new->statusCode = (int) $code;
125
+ if (!$reasonPhrase && isset(self::$phrases[$new->statusCode])) {
126
+ $reasonPhrase = self::$phrases[$new->statusCode];
127
+ }
128
+ $new->reasonPhrase = $reasonPhrase;
129
+ return $new;
130
+ }
131
+ }
app/api/Ctct/vendor/guzzlehttp/psr7/src/Stream.php ADDED
@@ -0,0 +1,245 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Psr7;
3
+
4
+ use Psr\Http\Message\StreamInterface;
5
+
6
+ /**
7
+ * PHP stream implementation.
8
+ *
9
+ * @var $stream
10
+ */
11
+ class Stream implements StreamInterface
12
+ {
13
+ private $stream;
14
+ private $size;
15
+ private $seekable;
16
+ private $readable;
17
+ private $writable;
18
+ private $uri;
19
+ private $customMetadata;
20
+
21
+ /** @var array Hash of readable and writable stream types */
22
+ private static $readWriteHash = [
23
+ 'read' => [
24
+ 'r' => true, 'w+' => true, 'r+' => true, 'x+' => true, 'c+' => true,
25
+ 'rb' => true, 'w+b' => true, 'r+b' => true, 'x+b' => true,
26
+ 'c+b' => true, 'rt' => true, 'w+t' => true, 'r+t' => true,
27
+ 'x+t' => true, 'c+t' => true, 'a+' => true
28
+ ],
29
+ 'write' => [
30
+ 'w' => true, 'w+' => true, 'rw' => true, 'r+' => true, 'x+' => true,
31
+ 'c+' => true, 'wb' => true, 'w+b' => true, 'r+b' => true,
32
+ 'x+b' => true, 'c+b' => true, 'w+t' => true, 'r+t' => true,
33
+ 'x+t' => true, 'c+t' => true, 'a' => true, 'a+' => true
34
+ ]
35
+ ];
36
+
37
+ /**
38
+ * This constructor accepts an associative array of options.
39
+ *
40
+ * - size: (int) If a read stream would otherwise have an indeterminate
41
+ * size, but the size is known due to foreknownledge, then you can
42
+ * provide that size, in bytes.
43
+ * - metadata: (array) Any additional metadata to return when the metadata
44
+ * of the stream is accessed.
45
+ *
46
+ * @param resource $stream Stream resource to wrap.
47
+ * @param array $options Associative array of options.
48
+ *
49
+ * @throws \InvalidArgumentException if the stream is not a stream resource
50
+ */
51
+ public function __construct($stream, $options = [])
52
+ {
53
+ if (!is_resource($stream)) {
54
+ throw new \InvalidArgumentException('Stream must be a resource');
55
+ }
56
+
57
+ if (isset($options['size'])) {
58
+ $this->size = $options['size'];
59
+ }
60
+
61
+ $this->customMetadata = isset($options['metadata'])
62
+ ? $options['metadata']
63
+ : [];
64
+
65
+ $this->stream = $stream;
66
+ $meta = stream_get_meta_data($this->stream);
67
+ $this->seekable = $meta['seekable'];
68
+ $this->readable = isset(self::$readWriteHash['read'][$meta['mode']]);
69
+ $this->writable = isset(self::$readWriteHash['write'][$meta['mode']]);
70
+ $this->uri = $this->getMetadata('uri');
71
+ }
72
+
73
+ public function __get($name)
74
+ {
75
+ if ($name == 'stream') {
76
+ throw new \RuntimeException('The stream is detached');
77
+ }
78
+
79
+ throw new \BadMethodCallException('No value for ' . $name);
80
+ }
81
+
82
+ /**
83
+ * Closes the stream when the destructed
84
+ */
85
+ public function __destruct()
86
+ {
87
+ $this->close();
88
+ }
89
+
90
+ public function __toString()
91
+ {
92
+ try {
93
+ $this->seek(0);
94
+ return (string) stream_get_contents($this->stream);
95
+ } catch (\Exception $e) {
96
+ return '';
97
+ }
98
+ }
99
+
100
+ public function getContents()
101
+ {
102
+ $contents = stream_get_contents($this->stream);
103
+
104
+ if ($contents === false) {
105
+ throw new \RuntimeException('Unable to read stream contents');
106
+ }
107
+
108
+ return $contents;
109
+ }
110
+
111
+ public function close()
112
+ {
113
+ if (isset($this->stream)) {
114
+ if (is_resource($this->stream)) {
115
+ fclose($this->stream);
116
+ }
117
+ $this->detach();
118
+ }
119
+ }
120
+
121
+ public function detach()
122
+ {
123
+ if (!isset($this->stream)) {
124
+ return null;
125
+ }
126
+
127
+ $result = $this->stream;
128
+ unset($this->stream);
129
+ $this->size = $this->uri = null;
130
+ $this->readable = $this->writable = $this->seekable = false;
131
+
132
+ return $result;
133
+ }
134
+
135
+ public function getSize()
136
+ {
137
+ if ($this->size !== null) {
138
+ return $this->size;
139
+ }
140
+
141
+ if (!isset($this->stream)) {
142
+ return null;
143
+ }
144
+
145
+ // Clear the stat cache if the stream has a URI
146
+ if ($this->uri) {
147
+ clearstatcache(true, $this->uri);
148
+ }
149
+
150
+ $stats = fstat($this->stream);
151
+ if (isset($stats['size'])) {
152
+ $this->size = $stats['size'];
153
+ return $this->size;
154
+ }
155
+
156
+ return null;
157
+ }
158
+
159
+ public function isReadable()
160
+ {
161
+ return $this->readable;
162
+ }
163
+
164
+ public function isWritable()
165
+ {
166
+ return $this->writable;
167
+ }
168
+
169
+ public function isSeekable()
170
+ {
171
+ return $this->seekable;
172
+ }
173
+
174
+ public function eof()
175
+ {
176
+ return !$this->stream || feof($this->stream);
177
+ }
178
+
179
+ public function tell()
180
+ {
181
+ $result = ftell($this->stream);
182
+
183
+ if ($result === false) {
184
+ throw new \RuntimeException('Unable to determine stream position');
185
+ }
186
+
187
+ return $result;
188
+ }
189
+
190
+ public function rewind()
191
+ {
192
+ $this->seek(0);
193
+ }
194
+
195
+ public function seek($offset, $whence = SEEK_SET)
196
+ {
197
+ if (!$this->seekable) {
198
+ throw new \RuntimeException('Stream is not seekable');
199
+ } elseif (fseek($this->stream, $offset, $whence) === -1) {
200
+ throw new \RuntimeException('Unable to seek to stream position '
201
+ . $offset . ' with whence ' . var_export($whence, true));
202
+ }
203
+ }
204
+
205
+ public function read($length)
206
+ {
207
+ if (!$this->readable) {
208
+ throw new \RuntimeException('Cannot read from non-readable stream');
209
+ }
210
+
211
+ return fread($this->stream, $length);
212
+ }
213
+
214
+ public function write($string)
215
+ {
216
+ if (!$this->writable) {
217
+ throw new \RuntimeException('Cannot write to a non-writable stream');
218
+ }
219
+
220
+ // We can't know the size after writing anything
221
+ $this->size = null;
222
+ $result = fwrite($this->stream, $string);
223
+
224
+ if ($result === false) {
225
+ throw new \RuntimeException('Unable to write to stream');
226
+ }
227
+
228
+ return $result;
229
+ }
230
+
231
+ public function getMetadata($key = null)
232
+ {
233
+ if (!isset($this->stream)) {
234
+ return $key ? null : [];
235
+ } elseif (!$key) {
236
+ return $this->customMetadata + stream_get_meta_data($this->stream);
237
+ } elseif (isset($this->customMetadata[$key])) {
238
+ return $this->customMetadata[$key];
239
+ }
240
+
241
+ $meta = stream_get_meta_data($this->stream);
242
+
243
+ return isset($meta[$key]) ? $meta[$key] : null;
244
+ }
245
+ }
app/api/Ctct/vendor/guzzlehttp/psr7/src/StreamDecoratorTrait.php ADDED
@@ -0,0 +1,149 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Psr7;
3
+
4
+ use Psr\Http\Message\StreamInterface;
5
+
6
+ /**
7
+ * Stream decorator trait
8
+ * @property StreamInterface stream
9
+ */
10
+ trait StreamDecoratorTrait
11
+ {
12
+ /**
13
+ * @param StreamInterface $stream Stream to decorate
14
+ */
15
+ public function __construct(StreamInterface $stream)
16
+ {
17
+ $this->stream = $stream;
18
+ }
19
+
20
+ /**
21
+ * Magic method used to create a new stream if streams are not added in
22
+ * the constructor of a decorator (e.g., LazyOpenStream).
23
+ *
24
+ * @param string $name Name of the property (allows "stream" only).
25
+ *
26
+ * @return StreamInterface
27
+ */
28
+ public function __get($name)
29
+ {
30
+ if ($name == 'stream') {
31
+ $this->stream = $this->createStream();
32
+ return $this->stream;
33
+ }
34
+
35
+ throw new \UnexpectedValueException("$name not found on class");
36
+ }
37
+
38
+ public function __toString()
39
+ {
40
+ try {
41
+ if ($this->isSeekable()) {
42
+ $this->seek(0);
43
+ }
44
+ return $this->getContents();
45
+ } catch (\Exception $e) {
46
+ // Really, PHP? https://bugs.php.net/bug.php?id=53648
47
+ trigger_error('StreamDecorator::__toString exception: '
48
+ . (string) $e, E_USER_ERROR);
49
+ return '';
50
+ }
51
+ }
52
+
53
+ public function getContents()
54
+ {
55
+ return copy_to_string($this);
56
+ }
57
+
58
+ /**
59
+ * Allow decorators to implement custom methods
60
+ *
61
+ * @param string $method Missing method name
62
+ * @param array $args Method arguments
63
+ *
64
+ * @return mixed
65
+ */
66
+ public function __call($method, array $args)
67
+ {
68
+ $result = call_user_func_array([$this->stream, $method], $args);
69
+
70
+ // Always return the wrapped object if the result is a return $this
71
+ return $result === $this->stream ? $this : $result;
72
+ }
73
+
74
+ public function close()
75
+ {
76
+ $this->stream->close();
77
+ }
78
+
79
+ public function getMetadata($key = null)
80
+ {
81
+ return $this->stream->getMetadata($key);
82
+ }
83
+
84
+ public function detach()
85
+ {
86
+ return $this->stream->detach();
87
+ }
88
+
89
+ public function getSize()
90
+ {
91
+ return $this->stream->getSize();
92
+ }
93
+
94
+ public function eof()
95
+ {
96
+ return $this->stream->eof();
97
+ }
98
+
99
+ public function tell()
100
+ {
101
+ return $this->stream->tell();
102
+ }
103
+
104
+ public function isReadable()
105
+ {
106
+ return $this->stream->isReadable();
107
+ }
108
+
109
+ public function isWritable()
110
+ {
111
+ return $this->stream->isWritable();
112
+ }
113
+
114
+ public function isSeekable()
115
+ {
116
+ return $this->stream->isSeekable();
117
+ }
118
+
119
+ public function rewind()
120
+ {
121
+ $this->seek(0);
122
+ }
123
+
124
+ public function seek($offset, $whence = SEEK_SET)
125
+ {
126
+ $this->stream->seek($offset, $whence);
127
+ }
128
+
129
+ public function read($length)
130
+ {
131
+ return $this->stream->read($length);
132
+ }
133
+
134
+ public function write($string)
135
+ {
136
+ return $this->stream->write($string);
137
+ }
138
+
139
+ /**
140
+ * Implement in subclasses to dynamically create streams when requested.
141
+ *
142
+ * @return StreamInterface
143
+ * @throws \BadMethodCallException
144
+ */
145
+ protected function createStream()
146
+ {
147
+ throw new \BadMethodCallException('Not implemented');
148
+ }
149
+ }
app/api/Ctct/vendor/guzzlehttp/psr7/src/StreamWrapper.php ADDED
@@ -0,0 +1,121 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Psr7;
3
+
4
+ use Psr\Http\Message\StreamInterface;
5
+
6
+ /**
7
+ * Converts Guzzle streams into PHP stream resources.
8
+ */
9
+ class StreamWrapper
10
+ {
11
+ /** @var resource */
12
+ public $context;
13
+
14
+ /** @var StreamInterface */
15
+ private $stream;
16
+
17
+ /** @var string r, r+, or w */
18
+ private $mode;
19
+
20
+ /**
21
+ * Returns a resource representing the stream.
22
+ *
23
+ * @param StreamInterface $stream The stream to get a resource for
24
+ *
25
+ * @return resource
26
+ * @throws \InvalidArgumentException if stream is not readable or writable
27
+ */
28
+ public static function getResource(StreamInterface $stream)
29
+ {
30
+ self::register();
31
+
32
+ if ($stream->isReadable()) {
33
+ $mode = $stream->isWritable() ? 'r+' : 'r';
34
+ } elseif ($stream->isWritable()) {
35
+ $mode = 'w';
36
+ } else {
37
+ throw new \InvalidArgumentException('The stream must be readable, '
38
+ . 'writable, or both.');
39
+ }
40
+
41
+ return fopen('guzzle://stream', $mode, null, stream_context_create([
42
+ 'guzzle' => ['stream' => $stream]
43
+ ]));
44
+ }
45
+
46
+ /**
47
+ * Registers the stream wrapper if needed
48
+ */
49
+ public static function register()
50
+ {
51
+ if (!in_array('guzzle', stream_get_wrappers())) {
52
+ stream_wrapper_register('guzzle', __CLASS__);
53
+ }
54
+ }
55
+
56
+ public function stream_open($path, $mode, $options, &$opened_path)
57
+ {
58
+ $options = stream_context_get_options($this->context);
59
+
60
+ if (!isset($options['guzzle']['stream'])) {
61
+ return false;
62
+ }
63
+
64
+ $this->mode = $mode;
65
+ $this->stream = $options['guzzle']['stream'];
66
+
67
+ return true;
68
+ }
69
+
70
+ public function stream_read($count)
71
+ {
72
+ return $this->stream->read($count);
73
+ }
74
+
75
+ public function stream_write($data)
76
+ {
77
+ return (int) $this->stream->write($data);
78
+ }
79
+
80
+ public function stream_tell()
81
+ {
82
+ return $this->stream->tell();
83
+ }
84
+
85
+ public function stream_eof()
86
+ {
87
+ return $this->stream->eof();
88
+ }
89
+
90
+ public function stream_seek($offset, $whence)
91
+ {
92
+ $this->stream->seek($offset, $whence);
93
+
94
+ return true;
95
+ }
96
+
97
+ public function stream_stat()
98
+ {
99
+ static $modeMap = [
100
+ 'r' => 33060,
101
+ 'r+' => 33206,
102
+ 'w' => 33188
103
+ ];
104
+
105
+ return [
106
+ 'dev' => 0,
107
+ 'ino' => 0,
108
+ 'mode' => $modeMap[$this->mode],
109
+ 'nlink' => 0,
110
+ 'uid' => 0,
111
+ 'gid' => 0,
112
+ 'rdev' => 0,
113
+ 'size' => $this->stream->getSize() ?: 0,
114
+ 'atime' => 0,
115
+ 'mtime' => 0,
116
+ 'ctime' => 0,
117
+ 'blksize' => 0,
118
+ 'blocks' => 0
119
+ ];
120
+ }
121
+ }
app/api/Ctct/vendor/guzzlehttp/psr7/src/Uri.php ADDED
@@ -0,0 +1,606 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Psr7;
3
+
4
+ use Psr\Http\Message\UriInterface;
5
+
6
+ /**
7
+ * Basic PSR-7 URI implementation.
8
+ *
9
+ * @link https://github.com/phly/http This class is based upon
10
+ * Matthew Weier O'Phinney's URI implementation in phly/http.
11
+ */
12
+ class Uri implements UriInterface
13
+ {
14
+ private static $schemes = [
15
+ 'http' => 80,
16
+ 'https' => 443,
17
+ ];
18
+
19
+ private static $charUnreserved = 'a-zA-Z0-9_\-\.~';
20
+ private static $charSubDelims = '!\$&\'\(\)\*\+,;=';
21
+ private static $replaceQuery = ['=' => '%3D', '&' => '%26'];
22
+
23
+ /** @var string Uri scheme. */
24
+ private $scheme = '';
25
+
26
+ /** @var string Uri user info. */
27
+ private $userInfo = '';
28
+
29
+ /** @var string Uri host. */
30
+ private $host = '';
31
+
32
+ /** @var int|null Uri port. */
33
+ private $port;
34
+
35
+ /** @var string Uri path. */
36
+ private $path = '';
37
+
38
+ /** @var string Uri query string. */
39
+ private $query = '';
40
+
41
+ /** @var string Uri fragment. */
42
+ private $fragment = '';
43
+
44
+ /**
45
+ * @param string $uri URI to parse and wrap.
46
+ */
47
+ public function __construct($uri = '')
48
+ {
49
+ if ($uri != null) {
50
+ $parts = parse_url($uri);
51
+ if ($parts === false) {
52
+ throw new \InvalidArgumentException("Unable to parse URI: $uri");
53
+ }
54
+ $this->applyParts($parts);
55
+ }
56
+ }
57
+
58
+ public function __toString()
59
+ {
60
+ return self::createUriString(
61
+ $this->scheme,
62
+ $this->getAuthority(),
63
+ $this->getPath(),
64
+ $this->query,
65
+ $this->fragment
66
+ );
67
+ }
68
+
69
+ /**
70
+ * Removes dot segments from a path and returns the new path.
71
+ *
72
+ * @param string $path
73
+ *
74
+ * @return string
75
+ * @link http://tools.ietf.org/html/rfc3986#section-5.2.4
76
+ */
77
+ public static function removeDotSegments($path)
78
+ {
79
+ static $noopPaths = ['' => true, '/' => true, '*' => true];
80
+ static $ignoreSegments = ['.' => true, '..' => true];
81
+
82
+ if (isset($noopPaths[$path])) {
83
+ return $path;
84
+ }
85
+
86
+ $results = [];
87
+ $segments = explode('/', $path);
88
+ foreach ($segments as $segment) {
89
+ if ($segment == '..') {
90
+ array_pop($results);
91
+ } elseif (!isset($ignoreSegments[$segment])) {
92
+ $results[] = $segment;
93
+ }
94
+ }
95
+
96
+ $newPath = implode('/', $results);
97
+ // Add the leading slash if necessary
98
+ if (substr($path, 0, 1) === '/' &&
99
+ substr($newPath, 0, 1) !== '/'
100
+ ) {
101
+ $newPath = '/' . $newPath;
102
+ }
103
+
104
+ // Add the trailing slash if necessary
105
+ if ($newPath != '/' && isset($ignoreSegments[end($segments)])) {
106
+ $newPath .= '/';
107
+ }
108
+
109
+ return $newPath;
110
+ }
111
+
112
+ /**
113
+ * Resolve a base URI with a relative URI and return a new URI.
114
+ *
115
+ * @param UriInterface $base Base URI
116
+ * @param string $rel Relative URI
117
+ *
118
+ * @return UriInterface
119
+ */
120
+ public static function resolve(UriInterface $base, $rel)
121
+ {
122
+ if ($rel === null || $rel === '') {
123
+ return $base;
124
+ }
125
+
126
+ if (!($rel instanceof UriInterface)) {
127
+ $rel = new self($rel);
128
+ }
129
+
130
+ // Return the relative uri as-is if it has a scheme.
131
+ if ($rel->getScheme()) {
132
+ return $rel->withPath(static::removeDotSegments($rel->getPath()));
133
+ }
134
+
135
+ $relParts = [
136
+ 'scheme' => $rel->getScheme(),
137
+ 'authority' => $rel->getAuthority(),
138
+ 'path' => $rel->getPath(),
139
+ 'query' => $rel->getQuery(),
140
+ 'fragment' => $rel->getFragment()
141
+ ];
142
+
143
+ $parts = [
144
+ 'scheme' => $base->getScheme(),
145
+ 'authority' => $base->getAuthority(),
146
+ 'path' => $base->getPath(),
147
+ 'query' => $base->getQuery(),
148
+ 'fragment' => $base->getFragment()
149
+ ];
150
+
151
+ if (!empty($relParts['authority'])) {
152
+ $parts['authority'] = $relParts['authority'];
153
+ $parts['path'] = self::removeDotSegments($relParts['path']);
154
+ $parts['query'] = $relParts['query'];
155
+ $parts['fragment'] = $relParts['fragment'];
156
+ } elseif (!empty($relParts['path'])) {
157
+ if (substr($relParts['path'], 0, 1) == '/') {
158
+ $parts['path'] = self::removeDotSegments($relParts['path']);
159
+ $parts['query'] = $relParts['query'];
160
+ $parts['fragment'] = $relParts['fragment'];
161
+ } else {
162
+ if (!empty($parts['authority']) && empty($parts['path'])) {
163
+ $mergedPath = '/';
164
+ } else {
165
+ $mergedPath = substr($parts['path'], 0, strrpos($parts['path'], '/') + 1);
166
+ }
167
+ $parts['path'] = self::removeDotSegments($mergedPath . $relParts['path']);
168
+ $parts['query'] = $relParts['query'];
169
+ $parts['fragment'] = $relParts['fragment'];
170
+ }
171
+ } elseif (!empty($relParts['query'])) {
172
+ $parts['query'] = $relParts['query'];
173
+ } elseif ($relParts['fragment'] != null) {
174
+ $parts['fragment'] = $relParts['fragment'];
175
+ }
176
+
177
+ return new self(static::createUriString(
178
+ $parts['scheme'],
179
+ $parts['authority'],
180
+ $parts['path'],
181
+ $parts['query'],
182
+ $parts['fragment']
183
+ ));
184
+ }
185
+
186
+ /**
187
+ * Create a new URI with a specific query string value removed.
188
+ *
189
+ * Any existing query string values that exactly match the provided key are
190
+ * removed.
191
+ *
192
+ * Note: this function will convert "=" to "%3D" and "&" to "%26".
193
+ *
194
+ * @param UriInterface $uri URI to use as a base.
195
+ * @param string $key Query string key value pair to remove.
196
+ *
197
+ * @return UriInterface
198
+ */
199
+ public static function withoutQueryValue(UriInterface $uri, $key)
200
+ {
201
+ $current = $uri->getQuery();
202
+ if (!$current) {
203
+ return $uri;
204
+ }
205
+
206
+ $result = [];
207
+ foreach (explode('&', $current) as $part) {
208
+ if (explode('=', $part)[0] !== $key) {
209
+ $result[] = $part;
210
+ };
211
+ }
212
+
213
+ return $uri->withQuery(implode('&', $result));
214
+ }
215
+
216
+ /**
217
+ * Create a new URI with a specific query string value.
218
+ *
219
+ * Any existing query string values that exactly match the provided key are
220
+ * removed and replaced with the given key value pair.
221
+ *
222
+ * Note: this function will convert "=" to "%3D" and "&" to "%26".
223
+ *
224
+ * @param UriInterface $uri URI to use as a base.
225
+ * @param string $key Key to set.
226
+ * @param string $value Value to set.
227
+ *
228
+ * @return UriInterface
229
+ */
230
+ public static function withQueryValue(UriInterface $uri, $key, $value)
231
+ {
232
+ $current = $uri->getQuery();
233
+ $key = strtr($key, self::$replaceQuery);
234
+
235
+ if (!$current) {
236
+ $result = [];
237
+ } else {
238
+ $result = [];
239
+ foreach (explode('&', $current) as $part) {
240
+ if (explode('=', $part)[0] !== $key) {
241
+ $result[] = $part;
242
+ };
243
+ }
244
+ }
245
+
246
+ if ($value !== null) {
247
+ $result[] = $key . '=' . strtr($value, self::$replaceQuery);
248
+ } else {
249
+ $result[] = $key;
250
+ }
251
+
252
+ return $uri->withQuery(implode('&', $result));
253
+ }
254
+
255
+ /**
256
+ * Create a URI from a hash of parse_url parts.
257
+ *
258
+ * @param array $parts
259
+ *
260
+ * @return self
261
+ */
262
+ public static function fromParts(array $parts)
263
+ {
264
+ $uri = new self();
265
+ $uri->applyParts($parts);
266
+ return $uri;
267
+ }
268
+
269
+ public function getScheme()
270
+ {
271
+ return $this->scheme;
272
+ }
273
+
274
+ public function getAuthority()
275
+ {
276
+ if (empty($this->host)) {
277
+ return '';
278
+ }
279
+
280
+ $authority = $this->host;
281
+ if (!empty($this->userInfo)) {
282
+ $authority = $this->userInfo . '@' . $authority;
283
+ }
284
+
285
+ if ($this->isNonStandardPort($this->scheme, $this->host, $this->port)) {
286
+ $authority .= ':' . $this->port;
287
+ }
288
+
289
+ return $authority;
290
+ }
291
+
292
+ public function getUserInfo()
293
+ {
294
+ return $this->userInfo;
295
+ }
296
+
297
+ public function getHost()
298
+ {
299
+ return $this->host;
300
+ }
301
+
302
+ public function getPort()
303
+ {
304
+ return $this->port;
305
+ }
306
+
307
+ public function getPath()
308
+ {
309
+ return $this->path == null ? '' : $this->path;
310
+ }
311
+
312
+ public function getQuery()
313
+ {
314
+ return $this->query;
315
+ }
316
+
317
+ public function getFragment()
318
+ {
319
+ return $this->fragment;
320
+ }
321
+
322
+ public function withScheme($scheme)
323
+ {
324
+ $scheme = $this->filterScheme($scheme);
325
+
326
+ if ($this->scheme === $scheme) {
327
+ return $this;
328
+ }
329
+
330
+ $new = clone $this;
331
+ $new->scheme = $scheme;
332
+ $new->port = $new->filterPort($new->scheme, $new->host, $new->port);
333
+ return $new;
334
+ }
335
+
336
+ public function withUserInfo($user, $password = null)
337
+ {
338
+ $info = $user;
339
+ if ($password) {
340
+ $info .= ':' . $password;
341
+ }
342
+
343
+ if ($this->userInfo === $info) {
344
+ return $this;
345
+ }
346
+
347
+ $new = clone $this;
348
+ $new->userInfo = $info;
349
+ return $new;
350
+ }
351
+
352
+ public function withHost($host)
353
+ {
354
+ if ($this->host === $host) {
355
+ return $this;
356
+ }
357
+
358
+ $new = clone $this;
359
+ $new->host = $host;
360
+ return $new;
361
+ }
362
+
363
+ public function withPort($port)
364
+ {
365
+ $port = $this->filterPort($this->scheme, $this->host, $port);
366
+
367
+ if ($this->port === $port) {
368
+ return $this;
369
+ }
370
+
371
+ $new = clone $this;
372
+ $new->port = $port;
373
+ return $new;
374
+ }
375
+
376
+ public function withPath($path)
377
+ {
378
+ if (!is_string($path)) {
379
+ throw new \InvalidArgumentException(
380
+ 'Invalid path provided; must be a string'
381
+ );
382
+ }
383
+
384
+ $path = $this->filterPath($path);
385
+
386
+ if ($this->path === $path) {
387
+ return $this;
388
+ }
389
+
390
+ $new = clone $this;
391
+ $new->path = $path;
392
+ return $new;
393
+ }
394
+
395
+ public function withQuery($query)
396
+ {
397
+ if (!is_string($query) && !method_exists($query, '__toString')) {
398
+ throw new \InvalidArgumentException(
399
+ 'Query string must be a string'
400
+ );
401
+ }
402
+
403
+ $query = (string) $query;
404
+ if (substr($query, 0, 1) === '?') {
405
+ $query = substr($query, 1);
406
+ }
407
+
408
+ $query = $this->filterQueryAndFragment($query);
409
+
410
+ if ($this->query === $query) {
411
+ return $this;
412
+ }
413
+
414
+ $new = clone $this;
415
+ $new->query = $query;
416
+ return $new;
417
+ }
418
+
419
+ public function withFragment($fragment)
420
+ {
421
+ if (substr($fragment, 0, 1) === '#') {
422
+ $fragment = substr($fragment, 1);
423
+ }
424
+
425
+ $fragment = $this->filterQueryAndFragment($fragment);
426
+
427
+ if ($this->fragment === $fragment) {
428
+ return $this;
429
+ }
430
+
431
+ $new = clone $this;
432
+ $new->fragment = $fragment;
433
+ return $new;
434
+ }
435
+
436
+ /**
437
+ * Apply parse_url parts to a URI.
438
+ *
439
+ * @param $parts Array of parse_url parts to apply.
440
+ */
441
+ private function applyParts(array $parts)
442
+ {
443
+ $this->scheme = isset($parts['scheme'])
444
+ ? $this->filterScheme($parts['scheme'])
445
+ : '';
446
+ $this->userInfo = isset($parts['user']) ? $parts['user'] : '';
447
+ $this->host = isset($parts['host']) ? $parts['host'] : '';
448
+ $this->port = !empty($parts['port'])
449
+ ? $this->filterPort($this->scheme, $this->host, $parts['port'])
450
+ : null;
451
+ $this->path = isset($parts['path'])
452
+ ? $this->filterPath($parts['path'])
453
+ : '';
454
+ $this->query = isset($parts['query'])
455
+ ? $this->filterQueryAndFragment($parts['query'])
456
+ : '';
457
+ $this->fragment = isset($parts['fragment'])
458
+ ? $this->filterQueryAndFragment($parts['fragment'])
459
+ : '';
460
+ if (isset($parts['pass'])) {
461
+ $this->userInfo .= ':' . $parts['pass'];
462
+ }
463
+ }
464
+
465
+ /**
466
+ * Create a URI string from its various parts
467
+ *
468
+ * @param string $scheme
469
+ * @param string $authority
470
+ * @param string $path
471
+ * @param string $query
472
+ * @param string $fragment
473
+ * @return string
474
+ */
475
+ private static function createUriString($scheme, $authority, $path, $query, $fragment)
476
+ {
477
+ $uri = '';
478
+
479
+ if (!empty($scheme)) {
480
+ $uri .= $scheme . ':';
481
+ }
482
+
483
+ $hierPart = '';
484
+
485
+ if (!empty($authority)) {
486
+ if (!empty($scheme)) {
487
+ $hierPart .= '//';
488
+ }
489
+ $hierPart .= $authority;
490
+ }
491
+
492
+ if ($path != null) {
493
+ // Add a leading slash if necessary.
494
+ if ($hierPart && substr($path, 0, 1) !== '/') {
495
+ $hierPart .= '/';
496
+ }
497
+ $hierPart .= $path;
498
+ }
499
+
500
+ $uri .= $hierPart;
501
+
502
+ if ($query != null) {
503
+ $uri .= '?' . $query;
504
+ }
505
+
506
+ if ($fragment != null) {
507
+ $uri .= '#' . $fragment;
508
+ }
509
+
510
+ return $uri;
511
+ }
512
+
513
+ /**
514
+ * Is a given port non-standard for the current scheme?
515
+ *
516
+ * @param string $scheme
517
+ * @param string $host
518
+ * @param int $port
519
+ * @return bool
520
+ */
521
+ private static function isNonStandardPort($scheme, $host, $port)
522
+ {
523
+ if (!$scheme && $port) {
524
+ return true;
525
+ }
526
+
527
+ if (!$host || !$port) {
528
+ return false;
529
+ }
530
+
531
+ return !isset(static::$schemes[$scheme]) || $port !== static::$schemes[$scheme];
532
+ }
533
+
534
+ /**
535
+ * @param string $scheme
536
+ *
537
+ * @return string
538
+ */
539
+ private function filterScheme($scheme)
540
+ {
541
+ $scheme = strtolower($scheme);
542
+ $scheme = rtrim($scheme, ':/');
543
+
544
+ return $scheme;
545
+ }
546
+
547
+ /**
548
+ * @param string $scheme
549
+ * @param string $host
550
+ * @param int $port
551
+ *
552
+ * @return int|null
553
+ *
554
+ * @throws \InvalidArgumentException If the port is invalid.
555
+ */
556
+ private function filterPort($scheme, $host, $port)
557
+ {
558
+ if (null !== $port) {
559
+ $port = (int) $port;
560
+ if (1 > $port || 0xffff < $port) {
561
+ throw new \InvalidArgumentException(
562
+ sprintf('Invalid port: %d. Must be between 1 and 65535', $port)
563
+ );
564
+ }
565
+ }
566
+
567
+ return $this->isNonStandardPort($scheme, $host, $port) ? $port : null;
568
+ }
569
+
570
+ /**
571
+ * Filters the path of a URI
572
+ *
573
+ * @param $path
574
+ *
575
+ * @return string
576
+ */
577
+ private function filterPath($path)
578
+ {
579
+ return preg_replace_callback(
580
+ '/(?:[^' . self::$charUnreserved . self::$charSubDelims . ':@\/%]+|%(?![A-Fa-f0-9]{2}))/',
581
+ [$this, 'rawurlencodeMatchZero'],
582
+ $path
583
+ );
584
+ }
585
+
586
+ /**
587
+ * Filters the query string or fragment of a URI.
588
+ *
589
+ * @param $str
590
+ *
591
+ * @return string
592
+ */
593
+ private function filterQueryAndFragment($str)
594
+ {
595
+ return preg_replace_callback(
596
+ '/(?:[^' . self::$charUnreserved . self::$charSubDelims . '%:@\/\?]+|%(?![A-Fa-f0-9]{2}))/',
597
+ [$this, 'rawurlencodeMatchZero'],
598
+ $str
599
+ );
600
+ }
601
+
602
+ private function rawurlencodeMatchZero(array $match)
603
+ {
604
+ return rawurlencode($match[0]);
605
+ }
606
+ }
app/api/Ctct/vendor/guzzlehttp/psr7/src/functions.php ADDED
@@ -0,0 +1,810 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Psr7;
3
+
4
+ use Psr\Http\Message\MessageInterface;
5
+ use Psr\Http\Message\RequestInterface;
6
+ use Psr\Http\Message\ResponseInterface;
7
+ use Psr\Http\Message\StreamInterface;
8
+ use Psr\Http\Message\UriInterface;
9
+
10
+ /**
11
+ * Returns the string representation of an HTTP message.
12
+ *
13
+ * @param MessageInterface $message Message to convert to a string.
14
+ *
15
+ * @return string
16
+ */
17
+ function str(MessageInterface $message)
18
+ {
19
+ if ($message instanceof RequestInterface) {
20
+ $msg = trim($message->getMethod() . ' '
21
+ . $message->getRequestTarget())
22
+ . ' HTTP/' . $message->getProtocolVersion();
23
+ if (!$message->hasHeader('host')) {
24
+ $msg .= "\r\nHost: " . $message->getUri()->getHost();
25
+ }
26
+ } elseif ($message instanceof ResponseInterface) {
27
+ $msg = 'HTTP/' . $message->getProtocolVersion() . ' '
28
+ . $message->getStatusCode() . ' '
29
+ . $message->getReasonPhrase();
30
+ } else {
31
+ throw new \InvalidArgumentException('Unknown message type');
32
+ }
33
+
34
+ foreach ($message->getHeaders() as $name => $values) {
35
+ $msg .= "\r\n{$name}: " . implode(', ', $values);
36
+ }
37
+
38
+ return "{$msg}\r\n\r\n" . $message->getBody();
39
+ }
40
+
41
+ /**
42
+ * Returns a UriInterface for the given value.
43
+ *
44
+ * This function accepts a string or {@see Psr\Http\Message\UriInterface} and
45
+ * returns a UriInterface for the given value. If the value is already a
46
+ * `UriInterface`, it is returned as-is.
47
+ *
48
+ * @param string|UriInterface $uri
49
+ *
50
+ * @return UriInterface
51
+ * @throws \InvalidArgumentException
52
+ */
53
+ function uri_for($uri)
54
+ {
55
+ if ($uri instanceof UriInterface) {
56
+ return $uri;
57
+ } elseif (is_string($uri)) {
58
+ return new Uri($uri);
59
+ }
60
+
61
+ throw new \InvalidArgumentException('URI must be a string or UriInterface');
62
+ }
63
+
64
+ /**
65
+ * Create a new stream based on the input type.
66
+ *
67
+ * Options is an associative array that can contain the following keys:
68
+ * - metadata: Array of custom metadata.
69
+ * - size: Size of the stream.
70
+ *
71
+ * @param resource|string|StreamInterface $resource Entity body data
72
+ * @param array $options Additional options
73
+ *
74
+ * @return Stream
75
+ * @throws \InvalidArgumentException if the $resource arg is not valid.
76
+ */
77
+ function stream_for($resource = '', array $options = [])
78
+ {
79
+ switch (gettype($resource)) {
80
+ case 'string':
81
+ $stream = fopen('php://temp', 'r+');
82
+ if ($resource !== '') {
83
+ fwrite($stream, $resource);
84
+ fseek($stream, 0);
85
+ }
86
+ return new Stream($stream, $options);
87
+ case 'resource':
88
+ return new Stream($resource, $options);
89
+ case 'object':
90
+ if ($resource instanceof StreamInterface) {
91
+ return $resource;
92
+ } elseif ($resource instanceof \Iterator) {
93
+ return new PumpStream(function () use ($resource) {
94
+ if (!$resource->valid()) {
95
+ return false;
96
+ }
97
+ $result = $resource->current();
98
+ $resource->next();
99
+ return $result;
100
+ }, $options);
101
+ } elseif (method_exists($resource, '__toString')) {
102
+ return stream_for((string) $resource, $options);
103
+ }
104
+ break;
105
+ case 'NULL':
106
+ return new Stream(fopen('php://temp', 'r+'), $options);
107
+ }
108
+
109
+ if (is_callable($resource)) {
110
+ return new PumpStream($resource, $options);
111
+ }
112
+
113
+ throw new \InvalidArgumentException('Invalid resource type: ' . gettype($resource));
114
+ }
115
+
116
+ /**
117
+ * Parse an array of header values containing ";" separated data into an
118
+ * array of associative arrays representing the header key value pair
119
+ * data of the header. When a parameter does not contain a value, but just
120
+ * contains a key, this function will inject a key with a '' string value.
121
+ *
122
+ * @param string|array $header Header to parse into components.
123
+ *
124
+ * @return array Returns the parsed header values.
125
+ */
126
+ function parse_header($header)
127
+ {
128
+ static $trimmed = "\"' \n\t\r";
129
+ $params = $matches = [];
130
+
131
+ foreach (normalize_header($header) as $val) {
132
+ $part = [];
133
+ foreach (preg_split('/;(?=([^"]*"[^"]*")*[^"]*$)/', $val) as $kvp) {
134
+ if (preg_match_all('/<[^>]+>|[^=]+/', $kvp, $matches)) {
135
+ $m = $matches[0];
136
+ if (isset($m[1])) {
137
+ $part[trim($m[0], $trimmed)] = trim($m[1], $trimmed);
138
+ } else {
139
+ $part[] = trim($m[0], $trimmed);
140
+ }
141
+ }
142
+ }
143
+ if ($part) {
144
+ $params[] = $part;
145
+ }
146
+ }
147
+
148
+ return $params;
149
+ }
150
+
151
+ /**
152
+ * Converts an array of header values that may contain comma separated
153
+ * headers into an array of headers with no comma separated values.
154
+ *
155
+ * @param string|array $header Header to normalize.
156
+ *
157
+ * @return array Returns the normalized header field values.
158
+ */
159
+ function normalize_header($header)
160
+ {
161
+ if (!is_array($header)) {
162
+ return array_map('trim', explode(',', $header));
163
+ }
164
+
165
+ $result = [];
166
+ foreach ($header as $value) {
167
+ foreach ((array) $value as $v) {
168
+ if (strpos($v, ',') === false) {
169
+ $result[] = $v;
170
+ continue;
171
+ }
172
+ foreach (preg_split('/,(?=([^"]*"[^"]*")*[^"]*$)/', $v) as $vv) {
173
+ $result[] = trim($vv);
174
+ }
175
+ }
176
+ }
177
+
178
+ return $result;
179
+ }
180
+
181
+ /**
182
+ * Clone and modify a request with the given changes.
183
+ *
184
+ * The changes can be one of:
185
+ * - method: (string) Changes the HTTP method.
186
+ * - set_headers: (array) Sets the given headers.
187
+ * - remove_headers: (array) Remove the given headers.
188
+ * - body: (mixed) Sets the given body.
189
+ * - uri: (UriInterface) Set the URI.
190
+ * - query: (string) Set the query string value of the URI.
191
+ * - version: (string) Set the protocol version.
192
+ *
193
+ * @param RequestInterface $request Request to clone and modify.
194
+ * @param array $changes Changes to apply.
195
+ *
196
+ * @return RequestInterface
197
+ */
198
+ function modify_request(RequestInterface $request, array $changes)
199
+ {
200
+ if (!$changes) {
201
+ return $request;
202
+ }
203
+
204
+ $headers = $request->getHeaders();
205
+
206
+ if (!isset($changes['uri'])) {
207
+ $uri = $request->getUri();
208
+ } else {
209
+ // Remove the host header if one is on the URI
210
+ if ($host = $changes['uri']->getHost()) {
211
+ $changes['set_headers']['Host'] = $host;
212
+
213
+ if ($port = $changes['uri']->getPort()) {
214
+ $standardPorts = ['http' => 80, 'https' => 443];
215
+ $scheme = $changes['uri']->getScheme();
216
+ if (isset($standardPorts[$scheme]) && $port != $standardPorts[$scheme]) {
217
+ $changes['set_headers']['Host'] .= ':'.$port;
218
+ }
219
+ }
220
+ }
221
+ $uri = $changes['uri'];
222
+ }
223
+
224
+ if (!empty($changes['remove_headers'])) {
225
+ $headers = _caseless_remove($changes['remove_headers'], $headers);
226
+ }
227
+
228
+ if (!empty($changes['set_headers'])) {
229
+ $headers = _caseless_remove(array_keys($changes['set_headers']), $headers);
230
+ $headers = $changes['set_headers'] + $headers;
231
+ }
232
+
233
+ if (isset($changes['query'])) {
234
+ $uri = $uri->withQuery($changes['query']);
235
+ }
236
+
237
+ return new Request(
238
+ isset($changes['method']) ? $changes['method'] : $request->getMethod(),
239
+ $uri,
240
+ $headers,
241
+ isset($changes['body']) ? $changes['body'] : $request->getBody(),
242
+ isset($changes['version'])
243
+ ? $changes['version']
244
+ : $request->getProtocolVersion()
245
+ );
246
+ }
247
+
248
+ /**
249
+ * Attempts to rewind a message body and throws an exception on failure.
250
+ *
251
+ * The body of the message will only be rewound if a call to `tell()` returns a
252
+ * value other than `0`.
253
+ *
254
+ * @param MessageInterface $message Message to rewind
255
+ *
256
+ * @throws \RuntimeException
257
+ */
258
+ function rewind_body(MessageInterface $message)
259
+ {
260
+ $body = $message->getBody();
261
+
262
+ if ($body->tell()) {
263
+ $body->rewind();
264
+ }
265
+ }
266
+
267
+ /**
268
+ * Safely opens a PHP stream resource using a filename.
269
+ *
270
+ * When fopen fails, PHP normally raises a warning. This function adds an
271
+ * error handler that checks for errors and throws an exception instead.
272
+ *
273
+ * @param string $filename File to open
274
+ * @param string $mode Mode used to open the file
275
+ *
276
+ * @return resource
277
+ * @throws \RuntimeException if the file cannot be opened
278
+ */
279
+ function try_fopen($filename, $mode)
280
+ {
281
+ $ex = null;
282
+ set_error_handler(function () use ($filename, $mode, &$ex) {
283
+ $ex = new \RuntimeException(sprintf(
284
+ 'Unable to open %s using mode %s: %s',
285
+ $filename,
286
+ $mode,
287
+ func_get_args()[1]
288
+ ));
289
+ });
290
+
291
+ $handle = fopen($filename, $mode);
292
+ restore_error_handler();
293
+
294
+ if ($ex) {
295
+ /** @var $ex \RuntimeException */
296
+ throw $ex;
297
+ }
298
+
299
+ return $handle;
300
+ }
301
+
302
+ /**
303
+ * Copy the contents of a stream into a string until the given number of
304
+ * bytes have been read.
305
+ *
306
+ * @param StreamInterface $stream Stream to read
307
+ * @param int $maxLen Maximum number of bytes to read. Pass -1
308
+ * to read the entire stream.
309
+ * @return string
310
+ * @throws \RuntimeException on error.
311
+ */
312
+ function copy_to_string(StreamInterface $stream, $maxLen = -1)
313
+ {
314
+ $buffer = '';
315
+
316
+ if ($maxLen === -1) {
317
+ while (!$stream->eof()) {
318
+ $buf = $stream->read(1048576);
319
+ // Using a loose equality here to match on '' and false.
320
+ if ($buf == null) {
321
+ break;
322
+ }
323
+ $buffer .= $buf;
324
+ }
325
+ return $buffer;
326
+ }
327
+
328
+ $len = 0;
329
+ while (!$stream->eof() && $len < $maxLen) {
330
+ $buf = $stream->read($maxLen - $len);
331
+ // Using a loose equality here to match on '' and false.
332
+ if ($buf == null) {
333
+ break;
334
+ }
335
+ $buffer .= $buf;
336
+ $len = strlen($buffer);
337
+ }
338
+
339
+ return $buffer;
340
+ }
341
+
342
+ /**
343
+ * Copy the contents of a stream into another stream until the given number
344
+ * of bytes have been read.
345
+ *
346
+ * @param StreamInterface $source Stream to read from
347
+ * @param StreamInterface $dest Stream to write to
348
+ * @param int $maxLen Maximum number of bytes to read. Pass -1
349
+ * to read the entire stream.
350
+ *
351
+ * @throws \RuntimeException on error.
352
+ */
353
+ function copy_to_stream(
354
+ StreamInterface $source,
355
+ StreamInterface $dest,
356
+ $maxLen = -1
357
+ ) {
358
+ if ($maxLen === -1) {
359
+ while (!$source->eof()) {
360
+ if (!$dest->write($source->read(1048576))) {
361
+ break;
362
+ }
363
+ }
364
+ return;
365
+ }
366
+
367
+ $bytes = 0;
368
+ while (!$source->eof()) {
369
+ $buf = $source->read($maxLen - $bytes);
370
+ if (!($len = strlen($buf))) {
371
+ break;
372
+ }
373
+ $bytes += $len;
374
+ $dest->write($buf);
375
+ if ($bytes == $maxLen) {
376
+ break;
377
+ }
378
+ }
379
+ }
380
+
381
+ /**
382
+ * Calculate a hash of a Stream
383
+ *
384
+ * @param StreamInterface $stream Stream to calculate the hash for
385
+ * @param string $algo Hash algorithm (e.g. md5, crc32, etc)
386
+ * @param bool $rawOutput Whether or not to use raw output
387
+ *
388
+ * @return string Returns the hash of the stream
389
+ * @throws \RuntimeException on error.
390
+ */
391
+ function hash(
392
+ StreamInterface $stream,
393
+ $algo,
394
+ $rawOutput = false
395
+ ) {
396
+ $pos = $stream->tell();
397
+
398
+ if ($pos > 0) {
399
+ $stream->rewind();
400
+ }
401
+
402
+ $ctx = hash_init($algo);
403
+ while (!$stream->eof()) {
404
+ hash_update($ctx, $stream->read(1048576));
405
+ }
406
+
407
+ $out = hash_final($ctx, (bool) $rawOutput);
408
+ $stream->seek($pos);
409
+
410
+ return $out;
411
+ }
412
+
413
+ /**
414
+ * Read a line from the stream up to the maximum allowed buffer length
415
+ *
416
+ * @param StreamInterface $stream Stream to read from
417
+ * @param int $maxLength Maximum buffer length
418
+ *
419
+ * @return string|bool
420
+ */
421
+ function readline(StreamInterface $stream, $maxLength = null)
422
+ {
423
+ $buffer = '';
424
+ $size = 0;
425
+
426
+ while (!$stream->eof()) {
427
+ // Using a loose equality here to match on '' and false.
428
+ if (null == ($byte = $stream->read(1))) {
429
+ return $buffer;
430
+ }
431
+ $buffer .= $byte;
432
+ // Break when a new line is found or the max length - 1 is reached
433
+ if ($byte == PHP_EOL || ++$size == $maxLength - 1) {
434
+ break;
435
+ }
436
+ }
437
+
438
+ return $buffer;
439
+ }
440
+
441
+ /**
442
+ * Parses a request message string into a request object.
443
+ *
444
+ * @param string $message Request message string.
445
+ *
446
+ * @return Request
447
+ */
448
+ function parse_request($message)
449
+ {
450
+ $data = _parse_message($message);
451
+ $matches = [];
452
+ if (!preg_match('/^[a-zA-Z]+\s+([a-zA-Z]+:\/\/|\/).*/', $data['start-line'], $matches)) {
453
+ throw new \InvalidArgumentException('Invalid request string');
454
+ }
455
+ $parts = explode(' ', $data['start-line'], 3);
456
+ $version = isset($parts[2]) ? explode('/', $parts[2])[1] : '1.1';
457
+
458
+ $request = new Request(
459
+ $parts[0],
460
+ $matches[1] === '/' ? _parse_request_uri($parts[1], $data['headers']) : $parts[1],
461
+ $data['headers'],
462
+ $data['body'],
463
+ $version
464
+ );
465
+
466
+ return $matches[1] === '/' ? $request : $request->withRequestTarget($parts[1]);
467
+ }
468
+
469
+ /**
470
+ * Parses a response message string into a response object.
471
+ *
472
+ * @param string $message Response message string.
473
+ *
474
+ * @return Response
475
+ */
476
+ function parse_response($message)
477
+ {
478
+ $data = _parse_message($message);
479
+ if (!preg_match('/^HTTP\/.* [0-9]{3} .*/', $data['start-line'])) {
480
+ throw new \InvalidArgumentException('Invalid response string');
481
+ }
482
+ $parts = explode(' ', $data['start-line'], 3);
483
+
484
+ return new Response(
485
+ $parts[1],
486
+ $data['headers'],
487
+ $data['body'],
488
+ explode('/', $parts[0])[1],
489
+ isset($parts[2]) ? $parts[2] : null
490
+ );
491
+ }
492
+
493
+ /**
494
+ * Parse a query string into an associative array.
495
+ *
496
+ * If multiple values are found for the same key, the value of that key
497
+ * value pair will become an array. This function does not parse nested
498
+ * PHP style arrays into an associative array (e.g., foo[a]=1&foo[b]=2 will
499
+ * be parsed into ['foo[a]' => '1', 'foo[b]' => '2']).
500
+ *
501
+ * @param string $str Query string to parse
502
+ * @param bool|string $urlEncoding How the query string is encoded
503
+ *
504
+ * @return array
505
+ */
506
+ function parse_query($str, $urlEncoding = true)
507
+ {
508
+ $result = [];
509
+
510
+ if ($str === '') {
511
+ return $result;
512
+ }
513
+
514
+ if ($urlEncoding === true) {
515
+ $decoder = function ($value) {
516
+ return rawurldecode(str_replace('+', ' ', $value));
517
+ };
518
+ } elseif ($urlEncoding == PHP_QUERY_RFC3986) {
519
+ $decoder = 'rawurldecode';
520
+ } elseif ($urlEncoding == PHP_QUERY_RFC1738) {
521
+ $decoder = 'urldecode';
522
+ } else {
523
+ $decoder = function ($str) { return $str; };
524
+ }
525
+
526
+ foreach (explode('&', $str) as $kvp) {
527
+ $parts = explode('=', $kvp, 2);
528
+ $key = $decoder($parts[0]);
529
+ $value = isset($parts[1]) ? $decoder($parts[1]) : null;
530
+ if (!isset($result[$key])) {
531
+ $result[$key] = $value;
532
+ } else {
533
+ if (!is_array($result[$key])) {
534
+ $result[$key] = [$result[$key]];
535
+ }
536
+ $result[$key][] = $value;
537
+ }
538
+ }
539
+
540
+ return $result;
541
+ }
542
+
543
+ /**
544
+ * Build a query string from an array of key value pairs.
545
+ *
546
+ * This function can use the return value of parseQuery() to build a query
547
+ * string. This function does not modify the provided keys when an array is
548
+ * encountered (like http_build_query would).
549
+ *
550
+ * @param array $params Query string parameters.
551
+ * @param int|false $encoding Set to false to not encode, PHP_QUERY_RFC3986
552
+ * to encode using RFC3986, or PHP_QUERY_RFC1738
553
+ * to encode using RFC1738.
554
+ * @return string
555
+ */
556
+ function build_query(array $params, $encoding = PHP_QUERY_RFC3986)
557
+ {
558
+ if (!$params) {
559
+ return '';
560
+ }
561
+
562
+ if ($encoding === false) {
563
+ $encoder = function ($str) { return $str; };
564
+ } elseif ($encoding == PHP_QUERY_RFC3986) {
565
+ $encoder = 'rawurlencode';
566
+ } elseif ($encoding == PHP_QUERY_RFC1738) {
567
+ $encoder = 'urlencode';
568
+ } else {
569
+ throw new \InvalidArgumentException('Invalid type');
570
+ }
571
+
572
+ $qs = '';
573
+ foreach ($params as $k => $v) {
574
+ $k = $encoder($k);
575
+ if (!is_array($v)) {
576
+ $qs .= $k;
577
+ if ($v !== null) {
578
+ $qs .= '=' . $encoder($v);
579
+ }
580
+ $qs .= '&';
581
+ } else {
582
+ foreach ($v as $vv) {
583
+ $qs .= $k;
584
+ if ($vv !== null) {
585
+ $qs .= '=' . $encoder($vv);
586
+ }
587
+ $qs .= '&';
588
+ }
589
+ }
590
+ }
591
+
592
+ return $qs ? (string) substr($qs, 0, -1) : '';
593
+ }
594
+
595
+ /**
596
+ * Determines the mimetype of a file by looking at its extension.
597
+ *
598
+ * @param $filename
599
+ *
600
+ * @return null|string
601
+ */
602
+ function mimetype_from_filename($filename)
603
+ {
604
+ return mimetype_from_extension(pathinfo($filename, PATHINFO_EXTENSION));
605
+ }
606
+
607
+ /**
608
+ * Maps a file extensions to a mimetype.
609
+ *
610
+ * @param $extension string The file extension.
611
+ *
612
+ * @return string|null
613
+ * @link http://svn.apache.org/repos/asf/httpd/httpd/branches/1.3.x/conf/mime.types
614
+ */
615
+ function mimetype_from_extension($extension)
616
+ {
617
+ static $mimetypes = [
618
+ '7z' => 'application/x-7z-compressed',
619
+ 'aac' => 'audio/x-aac',
620
+ 'ai' => 'application/postscript',
621
+ 'aif' => 'audio/x-aiff',
622
+ 'asc' => 'text/plain',
623
+ 'asf' => 'video/x-ms-asf',
624
+ 'atom' => 'application/atom+xml',
625
+ 'avi' => 'video/x-msvideo',
626
+ 'bmp' => 'image/bmp',
627
+ 'bz2' => 'application/x-bzip2',
628
+ 'cer' => 'application/pkix-cert',
629
+ 'crl' => 'application/pkix-crl',
630
+ 'crt' => 'application/x-x509-ca-cert',
631
+ 'css' => 'text/css',
632
+ 'csv' => 'text/csv',
633
+ 'cu' => 'application/cu-seeme',
634
+ 'deb' => 'application/x-debian-package',
635
+ 'doc' => 'application/msword',
636
+ 'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
637
+ 'dvi' => 'application/x-dvi',
638
+ 'eot' => 'application/vnd.ms-fontobject',
639
+ 'eps' => 'application/postscript',
640
+ 'epub' => 'application/epub+zip',
641
+ 'etx' => 'text/x-setext',
642
+ 'flac' => 'audio/flac',
643
+ 'flv' => 'video/x-flv',
644
+ 'gif' => 'image/gif',
645
+ 'gz' => 'application/gzip',
646
+ 'htm' => 'text/html',
647
+ 'html' => 'text/html',
648
+ 'ico' => 'image/x-icon',
649
+ 'ics' => 'text/calendar',
650
+ 'ini' => 'text/plain',
651
+ 'iso' => 'application/x-iso9660-image',
652
+ 'jar' => 'application/java-archive',
653
+ 'jpe' => 'image/jpeg',
654
+ 'jpeg' => 'image/jpeg',
655
+ 'jpg' => 'image/jpeg',
656
+ 'js' => 'text/javascript',
657
+ 'json' => 'application/json',
658
+ 'latex' => 'application/x-latex',
659
+ 'log' => 'text/plain',
660
+ 'm4a' => 'audio/mp4',
661
+ 'm4v' => 'video/mp4',
662
+ 'mid' => 'audio/midi',
663
+ 'midi' => 'audio/midi',
664
+ 'mov' => 'video/quicktime',
665
+ 'mp3' => 'audio/mpeg',
666
+ 'mp4' => 'video/mp4',
667
+ 'mp4a' => 'audio/mp4',
668
+ 'mp4v' => 'video/mp4',
669
+ 'mpe' => 'video/mpeg',
670
+ 'mpeg' => 'video/mpeg',
671
+ 'mpg' => 'video/mpeg',
672
+ 'mpg4' => 'video/mp4',
673
+ 'oga' => 'audio/ogg',
674
+ 'ogg' => 'audio/ogg',
675
+ 'ogv' => 'video/ogg',
676
+ 'ogx' => 'application/ogg',
677
+ 'pbm' => 'image/x-portable-bitmap',
678
+ 'pdf' => 'application/pdf',
679
+ 'pgm' => 'image/x-portable-graymap',
680
+ 'png' => 'image/png',
681
+ 'pnm' => 'image/x-portable-anymap',
682
+ 'ppm' => 'image/x-portable-pixmap',
683
+ 'ppt' => 'application/vnd.ms-powerpoint',
684
+ 'pptx' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
685
+ 'ps' => 'application/postscript',
686
+ 'qt' => 'video/quicktime',
687
+ 'rar' => 'application/x-rar-compressed',
688
+ 'ras' => 'image/x-cmu-raster',
689
+ 'rss' => 'application/rss+xml',
690
+ 'rtf' => 'application/rtf',
691
+ 'sgm' => 'text/sgml',
692
+ 'sgml' => 'text/sgml',
693
+ 'svg' => 'image/svg+xml',
694
+ 'swf' => 'application/x-shockwave-flash',
695
+ 'tar' => 'application/x-tar',
696
+ 'tif' => 'image/tiff',
697
+ 'tiff' => 'image/tiff',
698
+ 'torrent' => 'application/x-bittorrent',
699
+ 'ttf' => 'application/x-font-ttf',
700
+ 'txt' => 'text/plain',
701
+ 'wav' => 'audio/x-wav',
702
+ 'webm' => 'video/webm',
703
+ 'wma' => 'audio/x-ms-wma',
704
+ 'wmv' => 'video/x-ms-wmv',
705
+ 'woff' => 'application/x-font-woff',
706
+ 'wsdl' => 'application/wsdl+xml',
707
+ 'xbm' => 'image/x-xbitmap',
708
+ 'xls' => 'application/vnd.ms-excel',
709
+ 'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
710
+ 'xml' => 'application/xml',
711
+ 'xpm' => 'image/x-xpixmap',
712
+ 'xwd' => 'image/x-xwindowdump',
713
+ 'yaml' => 'text/yaml',
714
+ 'yml' => 'text/yaml',
715
+ 'zip' => 'application/zip',
716
+ ];
717
+
718
+ $extension = strtolower($extension);
719
+
720
+ return isset($mimetypes[$extension])
721
+ ? $mimetypes[$extension]
722
+ : null;
723
+ }
724
+
725
+ /**
726
+ * Parses an HTTP message into an associative array.
727
+ *
728
+ * The array contains the "start-line" key containing the start line of
729
+ * the message, "headers" key containing an associative array of header
730
+ * array values, and a "body" key containing the body of the message.
731
+ *
732
+ * @param string $message HTTP request or response to parse.
733
+ *
734
+ * @return array
735
+ * @internal
736
+ */
737
+ function _parse_message($message)
738
+ {
739
+ if (!$message) {
740
+ throw new \InvalidArgumentException('Invalid message');
741
+ }
742
+
743
+ // Iterate over each line in the message, accounting for line endings
744
+ $lines = preg_split('/(\\r?\\n)/', $message, -1, PREG_SPLIT_DELIM_CAPTURE);
745
+ $result = ['start-line' => array_shift($lines), 'headers' => [], 'body' => ''];
746
+ array_shift($lines);
747
+
748
+ for ($i = 0, $totalLines = count($lines); $i < $totalLines; $i += 2) {
749
+ $line = $lines[$i];
750
+ // If two line breaks were encountered, then this is the end of body
751
+ if (empty($line)) {
752
+ if ($i < $totalLines - 1) {
753
+ $result['body'] = implode('', array_slice($lines, $i + 2));
754
+ }
755
+ break;
756
+ }
757
+ if (strpos($line, ':')) {
758
+ $parts = explode(':', $line, 2);
759
+ $key = trim($parts[0]);
760
+ $value = isset($parts[1]) ? trim($parts[1]) : '';
761
+ $result['headers'][$key][] = $value;
762
+ }
763
+ }
764
+
765
+ return $result;
766
+ }
767
+
768
+ /**
769
+ * Constructs a URI for an HTTP request message.
770
+ *
771
+ * @param string $path Path from the start-line
772
+ * @param array $headers Array of headers (each value an array).
773
+ *
774
+ * @return string
775
+ * @internal
776
+ */
777
+ function _parse_request_uri($path, array $headers)
778
+ {
779
+ $hostKey = array_filter(array_keys($headers), function ($k) {
780
+ return strtolower($k) === 'host';
781
+ });
782
+
783
+ // If no host is found, then a full URI cannot be constructed.
784
+ if (!$hostKey) {
785
+ return $path;
786
+ }
787
+
788
+ $host = $headers[reset($hostKey)][0];
789
+ $scheme = substr($host, -4) === ':443' ? 'https' : 'http';
790
+
791
+ return $scheme . '://' . $host . '/' . ltrim($path, '/');
792
+ }
793
+
794
+ /** @internal */
795
+ function _caseless_remove($keys, array $data)
796
+ {
797
+ $result = [];
798
+
799
+ foreach ($keys as &$key) {
800
+ $key = strtolower($key);
801
+ }
802
+
803
+ foreach ($data as $k => $v) {
804
+ if (!in_array(strtolower($k), $keys)) {
805
+ $result[$k] = $v;
806
+ }
807
+ }
808
+
809
+ return $result;
810
+ }
app/api/Ctct/vendor/guzzlehttp/psr7/src/functions_include.php ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // Don't redefine the functions if included multiple times.
4
+ if (!function_exists('GuzzleHttp\Psr7\str')) {
5
+ require __DIR__ . '/functions.php';
6
+ }
app/api/Ctct/vendor/guzzlehttp/psr7/tests/AppendStreamTest.php ADDED
@@ -0,0 +1,186 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Tests\Psr7;
3
+
4
+ use GuzzleHttp\Psr7\AppendStream;
5
+ use GuzzleHttp\Psr7;
6
+
7
+ class AppendStreamTest extends \PHPUnit_Framework_TestCase
8
+ {
9
+ /**
10
+ * @expectedException \InvalidArgumentException
11
+ * @expectedExceptionMessage Each stream must be readable
12
+ */
13
+ public function testValidatesStreamsAreReadable()
14
+ {
15
+ $a = new AppendStream();
16
+ $s = $this->getMockBuilder('Psr\Http\Message\StreamInterface')
17
+ ->setMethods(['isReadable'])
18
+ ->getMockForAbstractClass();
19
+ $s->expects($this->once())
20
+ ->method('isReadable')
21
+ ->will($this->returnValue(false));
22
+ $a->addStream($s);
23
+ }
24
+
25
+ /**
26
+ * @expectedException \RuntimeException
27
+ * @expectedExceptionMessage The AppendStream can only seek with SEEK_SET
28
+ */
29
+ public function testValidatesSeekType()
30
+ {
31
+ $a = new AppendStream();
32
+ $a->seek(100, SEEK_CUR);
33
+ }
34
+
35
+ /**
36
+ * @expectedException \RuntimeException
37
+ * @expectedExceptionMessage Unable to seek stream 0 of the AppendStream
38
+ */
39
+ public function testTriesToRewindOnSeek()
40
+ {
41
+ $a = new AppendStream();
42
+ $s = $this->getMockBuilder('Psr\Http\Message\StreamInterface')
43
+ ->setMethods(['isReadable', 'rewind', 'isSeekable'])
44
+ ->getMockForAbstractClass();
45
+ $s->expects($this->once())
46
+ ->method('isReadable')
47
+ ->will($this->returnValue(true));
48
+ $s->expects($this->once())
49
+ ->method('isSeekable')
50
+ ->will($this->returnValue(true));
51
+ $s->expects($this->once())
52
+ ->method('rewind')
53
+ ->will($this->throwException(new \RuntimeException()));
54
+ $a->addStream($s);
55
+ $a->seek(10);
56
+ }
57
+
58
+ public function testSeeksToPositionByReading()
59
+ {
60
+ $a = new AppendStream([
61
+ Psr7\stream_for('foo'),
62
+ Psr7\stream_for('bar'),
63
+ Psr7\stream_for('baz'),
64
+ ]);
65
+
66
+ $a->seek(3);
67
+ $this->assertEquals(3, $a->tell());
68
+ $this->assertEquals('bar', $a->read(3));
69
+
70
+ $a->seek(6);
71
+ $this->assertEquals(6, $a->tell());
72
+ $this->assertEquals('baz', $a->read(3));
73
+ }
74
+
75
+ public function testDetachesEachStream()
76
+ {
77
+ $s1 = Psr7\stream_for('foo');
78
+ $s2 = Psr7\stream_for('bar');
79
+ $a = new AppendStream([$s1, $s2]);
80
+ $this->assertSame('foobar', (string) $a);
81
+ $a->detach();
82
+ $this->assertSame('', (string) $a);
83
+ $this->assertSame(0, $a->getSize());
84
+ }
85
+
86
+ public function testClosesEachStream()
87
+ {
88
+ $s1 = Psr7\stream_for('foo');
89
+ $a = new AppendStream([$s1]);
90
+ $a->close();
91
+ $this->assertSame('', (string) $a);
92
+ }
93
+
94
+ /**
95
+ * @expectedExceptionMessage Cannot write to an AppendStream
96
+ * @expectedException \RuntimeException
97
+ */
98
+ public function testIsNotWritable()
99
+ {
100
+ $a = new AppendStream([Psr7\stream_for('foo')]);
101
+ $this->assertFalse($a->isWritable());
102
+ $this->assertTrue($a->isSeekable());
103
+ $this->assertTrue($a->isReadable());
104
+ $a->write('foo');
105
+ }
106
+
107
+ public function testDoesNotNeedStreams()
108
+ {
109
+ $a = new AppendStream();
110
+ $this->assertEquals('', (string) $a);
111
+ }
112
+
113
+ public function testCanReadFromMultipleStreams()
114
+ {
115
+ $a = new AppendStream([
116
+ Psr7\stream_for('foo'),
117
+ Psr7\stream_for('bar'),
118
+ Psr7\stream_for('baz'),
119
+ ]);
120
+ $this->assertFalse($a->eof());
121
+ $this->assertSame(0, $a->tell());
122
+ $this->assertEquals('foo', $a->read(3));
123
+ $this->assertEquals('bar', $a->read(3));
124
+ $this->assertEquals('baz', $a->read(3));
125
+ $this->assertSame('', $a->read(1));
126
+ $this->assertTrue($a->eof());
127
+ $this->assertSame(9, $a->tell());
128
+ $this->assertEquals('foobarbaz', (string) $a);
129
+ }
130
+
131
+ public function testCanDetermineSizeFromMultipleStreams()
132
+ {
133
+ $a = new AppendStream([
134
+ Psr7\stream_for('foo'),
135
+ Psr7\stream_for('bar')
136
+ ]);
137
+ $this->assertEquals(6, $a->getSize());
138
+
139
+ $s = $this->getMockBuilder('Psr\Http\Message\StreamInterface')
140
+ ->setMethods(['isSeekable', 'isReadable'])
141
+ ->getMockForAbstractClass();
142
+ $s->expects($this->once())
143
+ ->method('isSeekable')
144
+ ->will($this->returnValue(null));
145
+ $s->expects($this->once())
146
+ ->method('isReadable')
147
+ ->will($this->returnValue(true));
148
+ $a->addStream($s);
149
+ $this->assertNull($a->getSize());
150
+ }
151
+
152
+ public function testCatchesExceptionsWhenCastingToString()
153
+ {
154
+ $s = $this->getMockBuilder('Psr\Http\Message\StreamInterface')
155
+ ->setMethods(['isSeekable', 'read', 'isReadable', 'eof'])
156
+ ->getMockForAbstractClass();
157
+ $s->expects($this->once())
158
+ ->method('isSeekable')
159
+ ->will($this->returnValue(true));
160
+ $s->expects($this->once())
161
+ ->method('read')
162
+ ->will($this->throwException(new \RuntimeException('foo')));
163
+ $s->expects($this->once())
164
+ ->method('isReadable')
165
+ ->will($this->returnValue(true));
166
+ $s->expects($this->any())
167
+ ->method('eof')
168
+ ->will($this->returnValue(false));
169
+ $a = new AppendStream([$s]);
170
+ $this->assertFalse($a->eof());
171
+ $this->assertSame('', (string) $a);
172
+ }
173
+
174
+ public function testCanDetach()
175
+ {
176
+ $s = new AppendStream();
177
+ $s->detach();
178
+ }
179
+
180
+ public function testReturnsEmptyMetadata()
181
+ {
182
+ $s = new AppendStream();
183
+ $this->assertEquals([], $s->getMetadata());
184
+ $this->assertNull($s->getMetadata('foo'));
185
+ }
186
+ }
app/api/Ctct/vendor/guzzlehttp/psr7/tests/BufferStreamTest.php ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Tests\Psr7;
3
+
4
+ use GuzzleHttp\Psr7\BufferStream;
5
+
6
+ class BufferStreamTest extends \PHPUnit_Framework_TestCase
7
+ {
8
+ public function testHasMetadata()
9
+ {
10
+ $b = new BufferStream(10);
11
+ $this->assertTrue($b->isReadable());
12
+ $this->assertTrue($b->isWritable());
13
+ $this->assertFalse($b->isSeekable());
14
+ $this->assertEquals(null, $b->getMetadata('foo'));
15
+ $this->assertEquals(10, $b->getMetadata('hwm'));
16
+ $this->assertEquals([], $b->getMetadata());
17
+ }
18
+
19
+ public function testRemovesReadDataFromBuffer()
20
+ {
21
+ $b = new BufferStream();
22
+ $this->assertEquals(3, $b->write('foo'));
23
+ $this->assertEquals(3, $b->getSize());
24
+ $this->assertFalse($b->eof());
25
+ $this->assertEquals('foo', $b->read(10));
26
+ $this->assertTrue($b->eof());
27
+ $this->assertEquals('', $b->read(10));
28
+ }
29
+
30
+ /**
31
+ * @expectedException \RuntimeException
32
+ * @expectedExceptionMessage Cannot determine the position of a BufferStream
33
+ */
34
+ public function testCanCastToStringOrGetContents()
35
+ {
36
+ $b = new BufferStream();
37
+ $b->write('foo');
38
+ $b->write('baz');
39
+ $this->assertEquals('foo', $b->read(3));
40
+ $b->write('bar');
41
+ $this->assertEquals('bazbar', (string) $b);
42
+ $b->tell();
43
+ }
44
+
45
+ public function testDetachClearsBuffer()
46
+ {
47
+ $b = new BufferStream();
48
+ $b->write('foo');
49
+ $b->detach();
50
+ $this->assertTrue($b->eof());
51
+ $this->assertEquals(3, $b->write('abc'));
52
+ $this->assertEquals('abc', $b->read(10));
53
+ }
54
+
55
+ public function testExceedingHighwaterMarkReturnsFalseButStillBuffers()
56
+ {
57
+ $b = new BufferStream(5);
58
+ $this->assertEquals(3, $b->write('hi '));
59
+ $this->assertFalse($b->write('hello'));
60
+ $this->assertEquals('hi hello', (string) $b);
61
+ $this->assertEquals(4, $b->write('test'));
62
+ }
63
+ }
app/api/Ctct/vendor/guzzlehttp/psr7/tests/CachingStreamTest.php ADDED
@@ -0,0 +1,166 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Tests\Psr7;
3
+
4
+ use GuzzleHttp\Psr7;
5
+ use GuzzleHttp\Psr7\CachingStream;
6
+
7
+ /**
8
+ * @covers GuzzleHttp\Psr7\CachingStream
9
+ */
10
+ class CachingStreamTest extends \PHPUnit_Framework_TestCase
11
+ {
12
+ /** @var CachingStream */
13
+ protected $body;
14
+ protected $decorated;
15
+
16
+ public function setUp()
17
+ {
18
+ $this->decorated = Psr7\stream_for('testing');
19
+ $this->body = new CachingStream($this->decorated);
20
+ }
21
+
22
+ public function tearDown()
23
+ {
24
+ $this->decorated->close();
25
+ $this->body->close();
26
+ }
27
+
28
+ public function testUsesRemoteSizeIfPossible()
29
+ {
30
+ $body = Psr7\stream_for('test');
31
+ $caching = new CachingStream($body);
32
+ $this->assertEquals(4, $caching->getSize());
33
+ }
34
+
35
+ public function testReadsUntilCachedToByte()
36
+ {
37
+ $this->body->seek(5);
38
+ $this->assertEquals('n', $this->body->read(1));
39
+ $this->body->seek(0);
40
+ $this->assertEquals('t', $this->body->read(1));
41
+ }
42
+
43
+ public function testCanSeekNearEndWithSeekEnd()
44
+ {
45
+ $baseStream = Psr7\stream_for(implode('', range('a', 'z')));
46
+ $cached = new CachingStream($baseStream);
47
+ $cached->seek(-1, SEEK_END);
48
+ $this->assertEquals(25, $baseStream->tell());
49
+ $this->assertEquals('z', $cached->read(1));
50
+ $this->assertEquals(26, $cached->getSize());
51
+ }
52
+
53
+ public function testCanSeekToEndWithSeekEnd()
54
+ {
55
+ $baseStream = Psr7\stream_for(implode('', range('a', 'z')));
56
+ $cached = new CachingStream($baseStream);
57
+ $cached->seek(0, SEEK_END);
58
+ $this->assertEquals(26, $baseStream->tell());
59
+ $this->assertEquals('', $cached->read(1));
60
+ $this->assertEquals(26, $cached->getSize());
61
+ }
62
+
63
+ public function testCanUseSeekEndWithUnknownSize()
64
+ {
65
+ $baseStream = Psr7\stream_for('testing');
66
+ $decorated = Psr7\FnStream::decorate($baseStream, [
67
+ 'getSize' => function () { return null; }
68
+ ]);
69
+ $cached = new CachingStream($decorated);
70
+ $cached->seek(-1, SEEK_END);
71
+ $this->assertEquals('g', $cached->read(1));
72
+ }
73
+
74
+ public function testRewindUsesSeek()
75
+ {
76
+ $a = Psr7\stream_for('foo');
77
+ $d = $this->getMockBuilder('GuzzleHttp\Psr7\CachingStream')
78
+ ->setMethods(array('seek'))
79
+ ->setConstructorArgs(array($a))
80
+ ->getMock();
81
+ $d->expects($this->once())
82
+ ->method('seek')
83
+ ->with(0)
84
+ ->will($this->returnValue(true));
85
+ $d->seek(0);
86
+ }
87
+
88
+ public function testCanSeekToReadBytes()
89
+ {
90
+ $this->assertEquals('te', $this->body->read(2));
91
+ $this->body->seek(0);
92
+ $this->assertEquals('test', $this->body->read(4));
93
+ $this->assertEquals(4, $this->body->tell());
94
+ $this->body->seek(2);
95
+ $this->assertEquals(2, $this->body->tell());
96
+ $this->body->seek(2, SEEK_CUR);
97
+ $this->assertEquals(4, $this->body->tell());
98
+ $this->assertEquals('ing', $this->body->read(3));
99
+ }
100
+
101
+ public function testWritesToBufferStream()
102
+ {
103
+ $this->body->read(2);
104
+ $this->body->write('hi');
105
+ $this->body->seek(0);
106
+ $this->assertEquals('tehiing', (string) $this->body);
107
+ }
108
+
109
+ public function testSkipsOverwrittenBytes()
110
+ {
111
+ $decorated = Psr7\stream_for(
112
+ implode("\n", array_map(function ($n) {
113
+ return str_pad($n, 4, '0', STR_PAD_LEFT);
114
+ }, range(0, 25)))
115
+ );
116
+
117
+ $body = new CachingStream($decorated);
118
+
119
+ $this->assertEquals("0000\n", Psr7\readline($body));
120
+ $this->assertEquals("0001\n", Psr7\readline($body));
121
+ // Write over part of the body yet to be read, so skip some bytes
122
+ $this->assertEquals(5, $body->write("TEST\n"));
123
+ $this->assertEquals(5, $this->readAttribute($body, 'skipReadBytes'));
124
+ // Read, which skips bytes, then reads
125
+ $this->assertEquals("0003\n", Psr7\readline($body));
126
+ $this->assertEquals(0, $this->readAttribute($body, 'skipReadBytes'));
127
+ $this->assertEquals("0004\n", Psr7\readline($body));
128
+ $this->assertEquals("0005\n", Psr7\readline($body));
129
+
130
+ // Overwrite part of the cached body (so don't skip any bytes)
131
+ $body->seek(5);
132
+ $this->assertEquals(5, $body->write("ABCD\n"));
133
+ $this->assertEquals(0, $this->readAttribute($body, 'skipReadBytes'));
134
+ $this->assertEquals("TEST\n", Psr7\readline($body));
135
+ $this->assertEquals("0003\n", Psr7\readline($body));
136
+ $this->assertEquals("0004\n", Psr7\readline($body));
137
+ $this->assertEquals("0005\n", Psr7\readline($body));
138
+ $this->assertEquals("0006\n", Psr7\readline($body));
139
+ $this->assertEquals(5, $body->write("1234\n"));
140
+ $this->assertEquals(5, $this->readAttribute($body, 'skipReadBytes'));
141
+
142
+ // Seek to 0 and ensure the overwritten bit is replaced
143
+ $body->seek(0);
144
+ $this->assertEquals("0000\nABCD\nTEST\n0003\n0004\n0005\n0006\n1234\n0008\n0009\n", $body->read(50));
145
+
146
+ // Ensure that casting it to a string does not include the bit that was overwritten
147
+ $this->assertContains("0000\nABCD\nTEST\n0003\n0004\n0005\n0006\n1234\n0008\n0009\n", (string) $body);
148
+ }
149
+
150
+ public function testClosesBothStreams()
151
+ {
152
+ $s = fopen('php://temp', 'r');
153
+ $a = Psr7\stream_for($s);
154
+ $d = new CachingStream($a);
155
+ $d->close();
156
+ $this->assertFalse(is_resource($s));
157
+ }
158
+
159
+ /**
160
+ * @expectedException \InvalidArgumentException
161
+ */
162
+ public function testEnsuresValidWhence()
163
+ {
164
+ $this->body->seek(10, -123456);
165
+ }
166
+ }
app/api/Ctct/vendor/guzzlehttp/psr7/tests/DroppingStreamTest.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Tests\Psr7;
3
+
4
+ use GuzzleHttp\Psr7\BufferStream;
5
+ use GuzzleHttp\Psr7\DroppingStream;
6
+
7
+ class DroppingStreamTest extends \PHPUnit_Framework_TestCase
8
+ {
9
+ public function testBeginsDroppingWhenSizeExceeded()
10
+ {
11
+ $stream = new BufferStream();
12
+ $drop = new DroppingStream($stream, 5);
13
+ $this->assertEquals(3, $drop->write('hel'));
14
+ $this->assertEquals(2, $drop->write('lo'));
15
+ $this->assertEquals(5, $drop->getSize());
16
+ $this->assertEquals('hello', $drop->read(5));
17
+ $this->assertEquals(0, $drop->getSize());
18
+ $drop->write('12345678910');
19
+ $this->assertEquals(5, $stream->getSize());
20
+ $this->assertEquals(5, $drop->getSize());
21
+ $this->assertEquals('12345', (string) $drop);
22
+ $this->assertEquals(0, $drop->getSize());
23
+ $drop->write('hello');
24
+ $this->assertSame(0, $drop->write('test'));
25
+ }
26
+ }
app/api/Ctct/vendor/guzzlehttp/psr7/tests/FnStreamTest.php ADDED
@@ -0,0 +1,90 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Tests\Psr7;
3
+
4
+ use GuzzleHttp\Psr7;
5
+ use GuzzleHttp\Psr7\FnStream;
6
+
7
+ /**
8
+ * @covers GuzzleHttp\Psr7\FnStream
9
+ */
10
+ class FnStreamTest extends \PHPUnit_Framework_TestCase
11
+ {
12
+ /**
13
+ * @expectedException \BadMethodCallException
14
+ * @expectedExceptionMessage seek() is not implemented in the FnStream
15
+ */
16
+ public function testThrowsWhenNotImplemented()
17
+ {
18
+ (new FnStream([]))->seek(1);
19
+ }
20
+
21
+ public function testProxiesToFunction()
22
+ {
23
+ $s = new FnStream([
24
+ 'read' => function ($len) {
25
+ $this->assertEquals(3, $len);
26
+ return 'foo';
27
+ }
28
+ ]);
29
+
30
+ $this->assertEquals('foo', $s->read(3));
31
+ }
32
+
33
+ public function testCanCloseOnDestruct()
34
+ {
35
+ $called = false;
36
+ $s = new FnStream([
37
+ 'close' => function () use (&$called) {
38
+ $called = true;
39
+ }
40
+ ]);
41
+ unset($s);
42
+ $this->assertTrue($called);
43
+ }
44
+
45
+ public function testDoesNotRequireClose()
46
+ {
47
+ $s = new FnStream([]);
48
+ unset($s);
49
+ }
50
+
51
+ public function testDecoratesStream()
52
+ {
53
+ $a = Psr7\stream_for('foo');
54
+ $b = FnStream::decorate($a, []);
55
+ $this->assertEquals(3, $b->getSize());
56
+ $this->assertEquals($b->isWritable(), true);
57
+ $this->assertEquals($b->isReadable(), true);
58
+ $this->assertEquals($b->isSeekable(), true);
59
+ $this->assertEquals($b->read(3), 'foo');
60
+ $this->assertEquals($b->tell(), 3);
61
+ $this->assertEquals($a->tell(), 3);
62
+ $this->assertSame('', $a->read(1));
63
+ $this->assertEquals($b->eof(), true);
64
+ $this->assertEquals($a->eof(), true);
65
+ $b->seek(0);
66
+ $this->assertEquals('foo', (string) $b);
67
+ $b->seek(0);
68
+ $this->assertEquals('foo', $b->getContents());
69
+ $this->assertEquals($a->getMetadata(), $b->getMetadata());
70
+ $b->seek(0, SEEK_END);
71
+ $b->write('bar');
72
+ $this->assertEquals('foobar', (string) $b);
73
+ $this->assertInternalType('resource', $b->detach());
74
+ $b->close();
75
+ }
76
+
77
+ public function testDecoratesWithCustomizations()
78
+ {
79
+ $called = false;
80
+ $a = Psr7\stream_for('foo');
81
+ $b = FnStream::decorate($a, [
82
+ 'read' => function ($len) use (&$called, $a) {
83
+ $called = true;
84
+ return $a->read($len);
85
+ }
86
+ ]);
87
+ $this->assertEquals('foo', $b->read(3));
88
+ $this->assertTrue($called);
89
+ }
90
+ }
app/api/Ctct/vendor/guzzlehttp/psr7/tests/FunctionsTest.php ADDED
@@ -0,0 +1,596 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Tests\Psr7;
3
+
4
+ use GuzzleHttp\Psr7;
5
+ use GuzzleHttp\Psr7\FnStream;
6
+ use GuzzleHttp\Psr7\NoSeekStream;
7
+
8
+ class FunctionsTest extends \PHPUnit_Framework_TestCase
9
+ {
10
+ public function testCopiesToString()
11
+ {
12
+ $s = Psr7\stream_for('foobaz');
13
+ $this->assertEquals('foobaz', Psr7\copy_to_string($s));
14
+ $s->seek(0);
15
+ $this->assertEquals('foo', Psr7\copy_to_string($s, 3));
16
+ $this->assertEquals('baz', Psr7\copy_to_string($s, 3));
17
+ $this->assertEquals('', Psr7\copy_to_string($s));
18
+ }
19
+
20
+ public function testCopiesToStringStopsWhenReadFails()
21
+ {
22
+ $s1 = Psr7\stream_for('foobaz');
23
+ $s1 = FnStream::decorate($s1, [
24
+ 'read' => function () { return ''; }
25
+ ]);
26
+ $result = Psr7\copy_to_string($s1);
27
+ $this->assertEquals('', $result);
28
+ }
29
+
30
+ public function testCopiesToStream()
31
+ {
32
+ $s1 = Psr7\stream_for('foobaz');
33
+ $s2 = Psr7\stream_for('');
34
+ Psr7\copy_to_stream($s1, $s2);
35
+ $this->assertEquals('foobaz', (string) $s2);
36
+ $s2 = Psr7\stream_for('');
37
+ $s1->seek(0);
38
+ Psr7\copy_to_stream($s1, $s2, 3);
39
+ $this->assertEquals('foo', (string) $s2);
40
+ Psr7\copy_to_stream($s1, $s2, 3);
41
+ $this->assertEquals('foobaz', (string) $s2);
42
+ }
43
+
44
+ public function testStopsCopyToStreamWhenWriteFails()
45
+ {
46
+ $s1 = Psr7\stream_for('foobaz');
47
+ $s2 = Psr7\stream_for('');
48
+ $s2 = FnStream::decorate($s2, ['write' => function () { return 0; }]);
49
+ Psr7\copy_to_stream($s1, $s2);
50
+ $this->assertEquals('', (string) $s2);
51
+ }
52
+
53
+ public function testStopsCopyToSteamWhenWriteFailsWithMaxLen()
54
+ {
55
+ $s1 = Psr7\stream_for('foobaz');
56
+ $s2 = Psr7\stream_for('');
57
+ $s2 = FnStream::decorate($s2, ['write' => function () { return 0; }]);
58
+ Psr7\copy_to_stream($s1, $s2, 10);
59
+ $this->assertEquals('', (string) $s2);
60
+ }
61
+
62
+ public function testStopsCopyToSteamWhenReadFailsWithMaxLen()
63
+ {
64
+ $s1 = Psr7\stream_for('foobaz');
65
+ $s1 = FnStream::decorate($s1, ['read' => function () { return ''; }]);
66
+ $s2 = Psr7\stream_for('');
67
+ Psr7\copy_to_stream($s1, $s2, 10);
68
+ $this->assertEquals('', (string) $s2);
69
+ }
70
+
71
+ public function testReadsLines()
72
+ {
73
+ $s = Psr7\stream_for("foo\nbaz\nbar");
74
+ $this->assertEquals("foo\n", Psr7\readline($s));
75
+ $this->assertEquals("baz\n", Psr7\readline($s));
76
+ $this->assertEquals("bar", Psr7\readline($s));
77
+ }
78
+
79
+ public function testReadsLinesUpToMaxLength()
80
+ {
81
+ $s = Psr7\stream_for("12345\n");
82
+ $this->assertEquals("123", Psr7\readline($s, 4));
83
+ $this->assertEquals("45\n", Psr7\readline($s));
84
+ }
85
+
86
+ public function testReadsLineUntilFalseReturnedFromRead()
87
+ {
88
+ $s = $this->getMockBuilder('GuzzleHttp\Psr7\Stream')
89
+ ->setMethods(['read', 'eof'])
90
+ ->disableOriginalConstructor()
91
+ ->getMock();
92
+ $s->expects($this->exactly(2))
93
+ ->method('read')
94
+ ->will($this->returnCallback(function () {
95
+ static $c = false;
96
+ if ($c) {
97
+ return false;
98
+ }
99
+ $c = true;
100
+ return 'h';
101
+ }));
102
+ $s->expects($this->exactly(2))
103
+ ->method('eof')
104
+ ->will($this->returnValue(false));
105
+ $this->assertEquals("h", Psr7\readline($s));
106
+ }
107
+
108
+ public function testCalculatesHash()
109
+ {
110
+ $s = Psr7\stream_for('foobazbar');
111
+ $this->assertEquals(md5('foobazbar'), Psr7\hash($s, 'md5'));
112
+ }
113
+
114
+ /**
115
+ * @expectedException \RuntimeException
116
+ */
117
+ public function testCalculatesHashThrowsWhenSeekFails()
118
+ {
119
+ $s = new NoSeekStream(Psr7\stream_for('foobazbar'));
120
+ $s->read(2);
121
+ Psr7\hash($s, 'md5');
122
+ }
123
+
124
+ public function testCalculatesHashSeeksToOriginalPosition()
125
+ {
126
+ $s = Psr7\stream_for('foobazbar');
127
+ $s->seek(4);
128
+ $this->assertEquals(md5('foobazbar'), Psr7\hash($s, 'md5'));
129
+ $this->assertEquals(4, $s->tell());
130
+ }
131
+
132
+ public function testOpensFilesSuccessfully()
133
+ {
134
+ $r = Psr7\try_fopen(__FILE__, 'r');
135
+ $this->assertInternalType('resource', $r);
136
+ fclose($r);
137
+ }
138
+
139
+ /**
140
+ * @expectedException \RuntimeException
141
+ * @expectedExceptionMessage Unable to open /path/to/does/not/exist using mode r
142
+ */
143
+ public function testThrowsExceptionNotWarning()
144
+ {
145
+ Psr7\try_fopen('/path/to/does/not/exist', 'r');
146
+ }
147
+
148
+ public function parseQueryProvider()
149
+ {
150
+ return [
151
+ // Does not need to parse when the string is empty
152
+ ['', []],
153
+ // Can parse mult-values items
154
+ ['q=a&q=b', ['q' => ['a', 'b']]],
155
+ // Can parse multi-valued items that use numeric indices
156
+ ['q[0]=a&q[1]=b', ['q[0]' => 'a', 'q[1]' => 'b']],
157
+ // Can parse duplicates and does not include numeric indices
158
+ ['q[]=a&q[]=b', ['q[]' => ['a', 'b']]],
159
+ // Ensures that the value of "q" is an array even though one value
160
+ ['q[]=a', ['q[]' => 'a']],
161
+ // Does not modify "." to "_" like PHP's parse_str()
162
+ ['q.a=a&q.b=b', ['q.a' => 'a', 'q.b' => 'b']],
163
+ // Can decode %20 to " "
164
+ ['q%20a=a%20b', ['q a' => 'a b']],
165
+ // Can parse funky strings with no values by assigning each to null
166
+ ['q&a', ['q' => null, 'a' => null]],
167
+ // Does not strip trailing equal signs
168
+ ['data=abc=', ['data' => 'abc=']],
169
+ // Can store duplicates without affecting other values
170
+ ['foo=a&foo=b&?µ=c', ['foo' => ['a', 'b'], '?µ' => 'c']],
171
+ // Sets value to null when no "=" is present
172
+ ['foo', ['foo' => null]],
173
+ // Preserves "0" keys.
174
+ ['0', ['0' => null]],
175
+ // Sets the value to an empty string when "=" is present
176
+ ['0=', ['0' => '']],
177
+ // Preserves falsey keys
178
+ ['var=0', ['var' => '0']],
179
+ ['a[b][c]=1&a[b][c]=2', ['a[b][c]' => ['1', '2']]],
180
+ ['a[b]=c&a[d]=e', ['a[b]' => 'c', 'a[d]' => 'e']],
181
+ // Ensure it doesn't leave things behind with repeated values
182
+ // Can parse mult-values items
183
+ ['q=a&q=b&q=c', ['q' => ['a', 'b', 'c']]],
184
+ ];
185
+ }
186
+
187
+ /**
188
+ * @dataProvider parseQueryProvider
189
+ */
190
+ public function testParsesQueries($input, $output)
191
+ {
192
+ $result = Psr7\parse_query($input);
193
+ $this->assertSame($output, $result);
194
+ }
195
+
196
+ public function testDoesNotDecode()
197
+ {
198
+ $str = 'foo%20=bar';
199
+ $data = Psr7\parse_query($str, false);
200
+ $this->assertEquals(['foo%20' => 'bar'], $data);
201
+ }
202
+
203
+ /**
204
+ * @dataProvider parseQueryProvider
205
+ */
206
+ public function testParsesAndBuildsQueries($input, $output)
207
+ {
208
+ $result = Psr7\parse_query($input, false);
209
+ $this->assertSame($input, Psr7\build_query($result, false));
210
+ }
211
+
212
+ public function testEncodesWithRfc1738()
213
+ {
214
+ $str = Psr7\build_query(['foo bar' => 'baz+'], PHP_QUERY_RFC1738);
215
+ $this->assertEquals('foo+bar=baz%2B', $str);
216
+ }
217
+
218
+ public function testEncodesWithRfc3986()
219
+ {
220
+ $str = Psr7\build_query(['foo bar' => 'baz+'], PHP_QUERY_RFC3986);
221
+ $this->assertEquals('foo%20bar=baz%2B', $str);
222
+ }
223
+
224
+ public function testDoesNotEncode()
225
+ {
226
+ $str = Psr7\build_query(['foo bar' => 'baz+'], false);
227
+ $this->assertEquals('foo bar=baz+', $str);
228
+ }
229
+
230
+ public function testCanControlDecodingType()
231
+ {
232
+ $result = Psr7\parse_query('var=foo+bar', PHP_QUERY_RFC3986);
233
+ $this->assertEquals('foo+bar', $result['var']);
234
+ $result = Psr7\parse_query('var=foo+bar', PHP_QUERY_RFC1738);
235
+ $this->assertEquals('foo bar', $result['var']);
236
+ }
237
+
238
+ public function testParsesRequestMessages()
239
+ {
240
+ $req = "GET /abc HTTP/1.0\r\nHost: foo.com\r\nFoo: Bar\r\nBaz: Bam\r\nBaz: Qux\r\n\r\nTest";
241
+ $request = Psr7\parse_request($req);
242
+ $this->assertEquals('GET', $request->getMethod());
243
+ $this->assertEquals('/abc', $request->getRequestTarget());
244
+ $this->assertEquals('1.0', $request->getProtocolVersion());
245
+ $this->assertEquals('foo.com', $request->getHeaderLine('Host'));
246
+ $this->assertEquals('Bar', $request->getHeaderLine('Foo'));
247
+ $this->assertEquals('Bam, Qux', $request->getHeaderLine('Baz'));
248
+ $this->assertEquals('Test', (string) $request->getBody());
249
+ $this->assertEquals('http://foo.com/abc', (string) $request->getUri());
250
+ }
251
+
252
+ public function testParsesRequestMessagesWithHttpsScheme()
253
+ {
254
+ $req = "PUT /abc?baz=bar HTTP/1.1\r\nHost: foo.com:443\r\n\r\n";
255
+ $request = Psr7\parse_request($req);
256
+ $this->assertEquals('PUT', $request->getMethod());
257
+ $this->assertEquals('/abc?baz=bar', $request->getRequestTarget());
258
+ $this->assertEquals('1.1', $request->getProtocolVersion());
259
+ $this->assertEquals('foo.com:443', $request->getHeaderLine('Host'));
260
+ $this->assertEquals('', (string) $request->getBody());
261
+ $this->assertEquals('https://foo.com/abc?baz=bar', (string) $request->getUri());
262
+ }
263
+
264
+ public function testParsesRequestMessagesWithUriWhenHostIsNotFirst()
265
+ {
266
+ $req = "PUT / HTTP/1.1\r\nFoo: Bar\r\nHost: foo.com\r\n\r\n";
267
+ $request = Psr7\parse_request($req);
268
+ $this->assertEquals('PUT', $request->getMethod());
269
+ $this->assertEquals('/', $request->getRequestTarget());
270
+ $this->assertEquals('http://foo.com/', (string) $request->getUri());
271
+ }
272
+
273
+ public function testParsesRequestMessagesWithFullUri()
274
+ {
275
+ $req = "GET https://www.google.com:443/search?q=foobar HTTP/1.1\r\nHost: www.google.com\r\n\r\n";
276
+ $request = Psr7\parse_request($req);
277
+ $this->assertEquals('GET', $request->getMethod());
278
+ $this->assertEquals('https://www.google.com:443/search?q=foobar', $request->getRequestTarget());
279
+ $this->assertEquals('1.1', $request->getProtocolVersion());
280
+ $this->assertEquals('www.google.com', $request->getHeaderLine('Host'));
281
+ $this->assertEquals('', (string) $request->getBody());
282
+ $this->assertEquals('https://www.google.com/search?q=foobar', (string) $request->getUri());
283
+ }
284
+
285
+ /**
286
+ * @expectedException \InvalidArgumentException
287
+ */
288
+ public function testValidatesRequestMessages()
289
+ {
290
+ Psr7\parse_request("HTTP/1.1 200 OK\r\n\r\n");
291
+ }
292
+
293
+ public function testParsesResponseMessages()
294
+ {
295
+ $res = "HTTP/1.0 200 OK\r\nFoo: Bar\r\nBaz: Bam\r\nBaz: Qux\r\n\r\nTest";
296
+ $response = Psr7\parse_response($res);
297
+ $this->assertEquals(200, $response->getStatusCode());
298
+ $this->assertEquals('OK', $response->getReasonPhrase());
299
+ $this->assertEquals('1.0', $response->getProtocolVersion());
300
+ $this->assertEquals('Bar', $response->getHeaderLine('Foo'));
301
+ $this->assertEquals('Bam, Qux', $response->getHeaderLine('Baz'));
302
+ $this->assertEquals('Test', (string) $response->getBody());
303
+ }
304
+
305
+ /**
306
+ * @expectedException \InvalidArgumentException
307
+ */
308
+ public function testValidatesResponseMessages()
309
+ {
310
+ Psr7\parse_response("GET / HTTP/1.1\r\n\r\n");
311
+ }
312
+
313
+ public function testDetermineMimetype()
314
+ {
315
+ $this->assertNull(Psr7\mimetype_from_extension('not-a-real-extension'));
316
+ $this->assertEquals(
317
+ 'application/json',
318
+ Psr7\mimetype_from_extension('json')
319
+ );
320
+ $this->assertEquals(
321
+ 'image/jpeg',
322
+ Psr7\mimetype_from_filename('/tmp/images/IMG034821.JPEG')
323
+ );
324
+ }
325
+
326
+ public function testCreatesUriForValue()
327
+ {
328
+ $this->assertInstanceOf('GuzzleHttp\Psr7\Uri', Psr7\uri_for('/foo'));
329
+ $this->assertInstanceOf(
330
+ 'GuzzleHttp\Psr7\Uri',
331
+ Psr7\uri_for(new Psr7\Uri('/foo'))
332
+ );
333
+ }
334
+
335
+ /**
336
+ * @expectedException \InvalidArgumentException
337
+ */
338
+ public function testValidatesUri()
339
+ {
340
+ Psr7\uri_for([]);
341
+ }
342
+
343
+ public function testKeepsPositionOfResource()
344
+ {
345
+ $h = fopen(__FILE__, 'r');
346
+ fseek($h, 10);
347
+ $stream = Psr7\stream_for($h);
348
+ $this->assertEquals(10, $stream->tell());
349
+ $stream->close();
350
+ }
351
+
352
+ public function testCreatesWithFactory()
353
+ {
354
+ $stream = Psr7\stream_for('foo');
355
+ $this->assertInstanceOf('GuzzleHttp\Psr7\Stream', $stream);
356
+ $this->assertEquals('foo', $stream->getContents());
357
+ $stream->close();
358
+ }
359
+
360
+ public function testFactoryCreatesFromEmptyString()
361
+ {
362
+ $s = Psr7\stream_for();
363
+ $this->assertInstanceOf('GuzzleHttp\Psr7\Stream', $s);
364
+ }
365
+
366
+ public function testFactoryCreatesFromNull()
367
+ {
368
+ $s = Psr7\stream_for(null);
369
+ $this->assertInstanceOf('GuzzleHttp\Psr7\Stream', $s);
370
+ }
371
+
372
+ public function testFactoryCreatesFromResource()
373
+ {
374
+ $r = fopen(__FILE__, 'r');
375
+ $s = Psr7\stream_for($r);
376
+ $this->assertInstanceOf('GuzzleHttp\Psr7\Stream', $s);
377
+ $this->assertSame(file_get_contents(__FILE__), (string) $s);
378
+ }
379
+
380
+ public function testFactoryCreatesFromObjectWithToString()
381
+ {
382
+ $r = new HasToString();
383
+ $s = Psr7\stream_for($r);
384
+ $this->assertInstanceOf('GuzzleHttp\Psr7\Stream', $s);
385
+ $this->assertEquals('foo', (string) $s);
386
+ }
387
+
388
+ public function testCreatePassesThrough()
389
+ {
390
+ $s = Psr7\stream_for('foo');
391
+ $this->assertSame($s, Psr7\stream_for($s));
392
+ }
393
+
394
+ /**
395
+ * @expectedException \InvalidArgumentException
396
+ */
397
+ public function testThrowsExceptionForUnknown()
398
+ {
399
+ Psr7\stream_for(new \stdClass());
400
+ }
401
+
402
+ public function testReturnsCustomMetadata()
403
+ {
404
+ $s = Psr7\stream_for('foo', ['metadata' => ['hwm' => 3]]);
405
+ $this->assertEquals(3, $s->getMetadata('hwm'));
406
+ $this->assertArrayHasKey('hwm', $s->getMetadata());
407
+ }
408
+
409
+ public function testCanSetSize()
410
+ {
411
+ $s = Psr7\stream_for('', ['size' => 10]);
412
+ $this->assertEquals(10, $s->getSize());
413
+ }
414
+
415
+ public function testCanCreateIteratorBasedStream()
416
+ {
417
+ $a = new \ArrayIterator(['foo', 'bar', '123']);
418
+ $p = Psr7\stream_for($a);
419
+ $this->assertInstanceOf('GuzzleHttp\Psr7\PumpStream', $p);
420
+ $this->assertEquals('foo', $p->read(3));
421
+ $this->assertFalse($p->eof());
422
+ $this->assertEquals('b', $p->read(1));
423
+ $this->assertEquals('a', $p->read(1));
424
+ $this->assertEquals('r12', $p->read(3));
425
+ $this->assertFalse($p->eof());
426
+ $this->assertEquals('3', $p->getContents());
427
+ $this->assertTrue($p->eof());
428
+ $this->assertEquals(9, $p->tell());
429
+ }
430
+
431
+ public function testConvertsRequestsToStrings()
432
+ {
433
+ $request = new Psr7\Request('PUT', 'http://foo.com/hi?123', [
434
+ 'Baz' => 'bar',
435
+ 'Qux' => ' ipsum'
436
+ ], 'hello', '1.0');
437
+ $this->assertEquals(
438
+ "PUT /hi?123 HTTP/1.0\r\nHost: foo.com\r\nBaz: bar\r\nQux: ipsum\r\n\r\nhello",
439
+ Psr7\str($request)
440
+ );
441
+ }
442
+
443
+ public function testConvertsResponsesToStrings()
444
+ {
445
+ $response = new Psr7\Response(200, [
446
+ 'Baz' => 'bar',
447
+ 'Qux' => ' ipsum'
448
+ ], 'hello', '1.0', 'FOO');
449
+ $this->assertEquals(
450
+ "HTTP/1.0 200 FOO\r\nBaz: bar\r\nQux: ipsum\r\n\r\nhello",
451
+ Psr7\str($response)
452
+ );
453
+ }
454
+
455
+ public function parseParamsProvider()
456
+ {
457
+ $res1 = array(
458
+ array(
459
+ '<http:/.../front.jpeg>',
460
+ 'rel' => 'front',
461
+ 'type' => 'image/jpeg',
462
+ ),
463
+ array(
464
+ '<http://.../back.jpeg>',
465
+ 'rel' => 'back',
466
+ 'type' => 'image/jpeg',
467
+ ),
468
+ );
469
+ return array(
470
+ array(
471
+ '<http:/.../front.jpeg>; rel="front"; type="image/jpeg", <http://.../back.jpeg>; rel=back; type="image/jpeg"',
472
+ $res1
473
+ ),
474
+ array(
475
+ '<http:/.../front.jpeg>; rel="front"; type="image/jpeg",<http://.../back.jpeg>; rel=back; type="image/jpeg"',
476
+ $res1
477
+ ),
478
+ array(
479
+ 'foo="baz"; bar=123, boo, test="123", foobar="foo;bar"',
480
+ array(
481
+ array('foo' => 'baz', 'bar' => '123'),
482
+ array('boo'),
483
+ array('test' => '123'),
484
+ array('foobar' => 'foo;bar')
485
+ )
486
+ ),
487
+ array(
488
+ '<http://.../side.jpeg?test=1>; rel="side"; type="image/jpeg",<http://.../side.jpeg?test=2>; rel=side; type="image/jpeg"',
489
+ array(
490
+ array('<http://.../side.jpeg?test=1>', 'rel' => 'side', 'type' => 'image/jpeg'),
491
+ array('<http://.../side.jpeg?test=2>', 'rel' => 'side', 'type' => 'image/jpeg')
492
+ )
493
+ ),
494
+ array(
495
+ '',
496
+ array()
497
+ )
498
+ );
499
+ }
500
+ /**
501
+ * @dataProvider parseParamsProvider
502
+ */
503
+ public function testParseParams($header, $result)
504
+ {
505
+ $this->assertEquals($result, Psr7\parse_header($header));
506
+ }
507
+
508
+ public function testParsesArrayHeaders()
509
+ {
510
+ $header = ['a, b', 'c', 'd, e'];
511
+ $this->assertEquals(['a', 'b', 'c', 'd', 'e'], Psr7\normalize_header($header));
512
+ }
513
+
514
+ public function testRewindsBody()
515
+ {
516
+ $body = Psr7\stream_for('abc');
517
+ $res = new Psr7\Response(200, [], $body);
518
+ Psr7\rewind_body($res);
519
+ $this->assertEquals(0, $body->tell());
520
+ $body->rewind(1);
521
+ Psr7\rewind_body($res);
522
+ $this->assertEquals(0, $body->tell());
523
+ }
524
+
525
+ /**
526
+ * @expectedException \RuntimeException
527
+ */
528
+ public function testThrowsWhenBodyCannotBeRewound()
529
+ {
530
+ $body = Psr7\stream_for('abc');
531
+ $body->read(1);
532
+ $body = FnStream::decorate($body, [
533
+ 'rewind' => function () { throw new \RuntimeException('a'); }
534
+ ]);
535
+ $res = new Psr7\Response(200, [], $body);
536
+ Psr7\rewind_body($res);
537
+ }
538
+
539
+ public function testCanModifyRequestWithUri()
540
+ {
541
+ $r1 = new Psr7\Request('GET', 'http://foo.com');
542
+ $r2 = Psr7\modify_request($r1, [
543
+ 'uri' => new Psr7\Uri('http://www.foo.com')
544
+ ]);
545
+ $this->assertEquals('http://www.foo.com', (string) $r2->getUri());
546
+ $this->assertEquals('www.foo.com', (string) $r2->getHeaderLine('host'));
547
+ }
548
+
549
+ public function testCanModifyRequestWithUriAndPort()
550
+ {
551
+ $r1 = new Psr7\Request('GET', 'http://foo.com:8000');
552
+ $r2 = Psr7\modify_request($r1, [
553
+ 'uri' => new Psr7\Uri('http://www.foo.com:8000')
554
+ ]);
555
+ $this->assertEquals('http://www.foo.com:8000', (string) $r2->getUri());
556
+ $this->assertEquals('www.foo.com:8000', (string) $r2->getHeaderLine('host'));
557
+ }
558
+
559
+ public function testCanModifyRequestWithCaseInsensitiveHeader()
560
+ {
561
+ $r1 = new Psr7\Request('GET', 'http://foo.com', ['User-Agent' => 'foo']);
562
+ $r2 = Psr7\modify_request($r1, ['set_headers' => ['User-agent' => 'bar']]);
563
+ $this->assertEquals('bar', $r2->getHeaderLine('User-Agent'));
564
+ $this->assertEquals('bar', $r2->getHeaderLine('User-agent'));
565
+ }
566
+
567
+ public function testReturnsAsIsWhenNoChanges()
568
+ {
569
+ $request = new Psr7\Request('GET', 'http://foo.com');
570
+ $this->assertSame($request, Psr7\modify_request($request, []));
571
+ }
572
+
573
+ public function testReturnsUriAsIsWhenNoChanges()
574
+ {
575
+ $r1 = new Psr7\Request('GET', 'http://foo.com');
576
+ $r2 = Psr7\modify_request($r1, ['set_headers' => ['foo' => 'bar']]);
577
+ $this->assertNotSame($r1, $r2);
578
+ $this->assertEquals('bar', $r2->getHeaderLine('foo'));
579
+ }
580
+
581
+ public function testRemovesHeadersFromMessage()
582
+ {
583
+ $r1 = new Psr7\Request('GET', 'http://foo.com', ['foo' => 'bar']);
584
+ $r2 = Psr7\modify_request($r1, ['remove_headers' => ['foo']]);
585
+ $this->assertNotSame($r1, $r2);
586
+ $this->assertFalse($r2->hasHeader('foo'));
587
+ }
588
+
589
+ public function testAddsQueryToUri()
590
+ {
591
+ $r1 = new Psr7\Request('GET', 'http://foo.com');
592
+ $r2 = Psr7\modify_request($r1, ['query' => 'foo=bar']);
593
+ $this->assertNotSame($r1, $r2);
594
+ $this->assertEquals('foo=bar', $r2->getUri()->getQuery());
595
+ }
596
+ }
app/api/Ctct/vendor/guzzlehttp/psr7/tests/InflateStreamTest.php ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Tests\Psr7;
3
+
4
+ use GuzzleHttp\Psr7;
5
+ use GuzzleHttp\Psr7\InflateStream;
6
+
7
+ class InflateStreamtest extends \PHPUnit_Framework_TestCase
8
+ {
9
+ public function testInflatesStreams()
10
+ {
11
+ $content = gzencode('test');
12
+ $a = Psr7\stream_for($content);
13
+ $b = new InflateStream($a);
14
+ $this->assertEquals('test', (string) $b);
15
+ }
16
+ }
app/api/Ctct/vendor/guzzlehttp/psr7/tests/LazyOpenStreamTest.php ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Tests\Psr7;
3
+
4
+ use GuzzleHttp\Psr7\LazyOpenStream;
5
+
6
+ class LazyOpenStreamTest extends \PHPUnit_Framework_TestCase
7
+ {
8
+ private $fname;
9
+
10
+ public function setup()
11
+ {
12
+ $this->fname = tempnam('/tmp', 'tfile');
13
+
14
+ if (file_exists($this->fname)) {
15
+ unlink($this->fname);
16
+ }
17
+ }
18
+
19
+ public function tearDown()
20
+ {
21
+ if (file_exists($this->fname)) {
22
+ unlink($this->fname);
23
+ }
24
+ }
25
+
26
+ public function testOpensLazily()
27
+ {
28
+ $l = new LazyOpenStream($this->fname, 'w+');
29
+ $l->write('foo');
30
+ $this->assertInternalType('array', $l->getMetadata());
31
+ $this->assertFileExists($this->fname);
32
+ $this->assertEquals('foo', file_get_contents($this->fname));
33
+ $this->assertEquals('foo', (string) $l);
34
+ }
35
+
36
+ public function testProxiesToFile()
37
+ {
38
+ file_put_contents($this->fname, 'foo');
39
+ $l = new LazyOpenStream($this->fname, 'r');
40
+ $this->assertEquals('foo', $l->read(4));
41
+ $this->assertTrue($l->eof());
42
+ $this->assertEquals(3, $l->tell());
43
+ $this->assertTrue($l->isReadable());
44
+ $this->assertTrue($l->isSeekable());
45
+ $this->assertFalse($l->isWritable());
46
+ $l->seek(1);
47
+ $this->assertEquals('oo', $l->getContents());
48
+ $this->assertEquals('foo', (string) $l);
49
+ $this->assertEquals(3, $l->getSize());
50
+ $this->assertInternalType('array', $l->getMetadata());
51
+ $l->close();
52
+ }
53
+
54
+ public function testDetachesUnderlyingStream()
55
+ {
56
+ file_put_contents($this->fname, 'foo');
57
+ $l = new LazyOpenStream($this->fname, 'r');
58
+ $r = $l->detach();
59
+ $this->assertInternalType('resource', $r);
60
+ fseek($r, 0);
61
+ $this->assertEquals('foo', stream_get_contents($r));
62
+ fclose($r);
63
+ }
64
+ }
app/api/Ctct/vendor/guzzlehttp/psr7/tests/LimitStreamTest.php ADDED
@@ -0,0 +1,166 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Tests\Psr7;
3
+
4
+ use GuzzleHttp\Psr7;
5
+ use GuzzleHttp\Psr7\FnStream;
6
+ use GuzzleHttp\Psr7\Stream;
7
+ use GuzzleHttp\Psr7\LimitStream;
8
+ use GuzzleHttp\Psr7\NoSeekStream;
9
+
10
+ /**
11
+ * @covers GuzzleHttp\Psr7\LimitStream
12
+ */
13
+ class LimitStreamTest extends \PHPUnit_Framework_TestCase
14
+ {
15
+ /** @var LimitStream */
16
+ protected $body;
17
+
18
+ /** @var Stream */
19
+ protected $decorated;
20
+
21
+ public function setUp()
22
+ {
23
+ $this->decorated = Psr7\stream_for(fopen(__FILE__, 'r'));
24
+ $this->body = new LimitStream($this->decorated, 10, 3);
25
+ }
26
+
27
+ public function testReturnsSubset()
28
+ {
29
+ $body = new LimitStream(Psr7\stream_for('foo'), -1, 1);
30
+ $this->assertEquals('oo', (string) $body);
31
+ $this->assertTrue($body->eof());
32
+ $body->seek(0);
33
+ $this->assertFalse($body->eof());
34
+ $this->assertEquals('oo', $body->read(100));
35
+ $this->assertSame('', $body->read(1));
36
+ $this->assertTrue($body->eof());
37
+ }
38
+
39
+ public function testReturnsSubsetWhenCastToString()
40
+ {
41
+ $body = Psr7\stream_for('foo_baz_bar');
42
+ $limited = new LimitStream($body, 3, 4);
43
+ $this->assertEquals('baz', (string) $limited);
44
+ }
45
+
46
+ /**
47
+ * @expectedException \RuntimeException
48
+ * @expectedExceptionMessage Unable to seek to stream position 10 with whence 0
49
+ */
50
+ public function testEnsuresPositionCanBeekSeekedTo()
51
+ {
52
+ new LimitStream(Psr7\stream_for(''), 0, 10);
53
+ }
54
+
55
+ public function testReturnsSubsetOfEmptyBodyWhenCastToString()
56
+ {
57
+ $body = Psr7\stream_for('01234567891234');
58
+ $limited = new LimitStream($body, 0, 10);
59
+ $this->assertEquals('', (string) $limited);
60
+ }
61
+
62
+ public function testReturnsSpecificSubsetOBodyWhenCastToString()
63
+ {
64
+ $body = Psr7\stream_for('0123456789abcdef');
65
+ $limited = new LimitStream($body, 3, 10);
66
+ $this->assertEquals('abc', (string) $limited);
67
+ }
68
+
69
+ public function testSeeksWhenConstructed()
70
+ {
71
+ $this->assertEquals(0, $this->body->tell());
72
+ $this->assertEquals(3, $this->decorated->tell());
73
+ }
74
+
75
+ public function testAllowsBoundedSeek()
76
+ {
77
+ $this->body->seek(100);
78
+ $this->assertEquals(10, $this->body->tell());
79
+ $this->assertEquals(13, $this->decorated->tell());
80
+ $this->body->seek(0);
81
+ $this->assertEquals(0, $this->body->tell());
82
+ $this->assertEquals(3, $this->decorated->tell());
83
+ try {
84
+ $this->body->seek(-10);
85
+ $this->fail();
86
+ } catch (\RuntimeException $e) {}
87
+ $this->assertEquals(0, $this->body->tell());
88
+ $this->assertEquals(3, $this->decorated->tell());
89
+ $this->body->seek(5);
90
+ $this->assertEquals(5, $this->body->tell());
91
+ $this->assertEquals(8, $this->decorated->tell());
92
+ // Fail
93
+ try {
94
+ $this->body->seek(1000, SEEK_END);
95
+ $this->fail();
96
+ } catch (\RuntimeException $e) {}
97
+ }
98
+
99
+ public function testReadsOnlySubsetOfData()
100
+ {
101
+ $data = $this->body->read(100);
102
+ $this->assertEquals(10, strlen($data));
103
+ $this->assertSame('', $this->body->read(1000));
104
+
105
+ $this->body->setOffset(10);
106
+ $newData = $this->body->read(100);
107
+ $this->assertEquals(10, strlen($newData));
108
+ $this->assertNotSame($data, $newData);
109
+ }
110
+
111
+ /**
112
+ * @expectedException \RuntimeException
113
+ * @expectedExceptionMessage Could not seek to stream offset 2
114
+ */
115
+ public function testThrowsWhenCurrentGreaterThanOffsetSeek()
116
+ {
117
+ $a = Psr7\stream_for('foo_bar');
118
+ $b = new NoSeekStream($a);
119
+ $c = new LimitStream($b);
120
+ $a->getContents();
121
+ $c->setOffset(2);
122
+ }
123
+
124
+ public function testCanGetContentsWithoutSeeking()
125
+ {
126
+ $a = Psr7\stream_for('foo_bar');
127
+ $b = new NoSeekStream($a);
128
+ $c = new LimitStream($b);
129
+ $this->assertEquals('foo_bar', $c->getContents());
130
+ }
131
+
132
+ public function testClaimsConsumedWhenReadLimitIsReached()
133
+ {
134
+ $this->assertFalse($this->body->eof());
135
+ $this->body->read(1000);
136
+ $this->assertTrue($this->body->eof());
137
+ }
138
+
139
+ public function testContentLengthIsBounded()
140
+ {
141
+ $this->assertEquals(10, $this->body->getSize());
142
+ }
143
+
144
+ public function testGetContentsIsBasedOnSubset()
145
+ {
146
+ $body = new LimitStream(Psr7\stream_for('foobazbar'), 3, 3);
147
+ $this->assertEquals('baz', $body->getContents());
148
+ }
149
+
150
+ public function testReturnsNullIfSizeCannotBeDetermined()
151
+ {
152
+ $a = new FnStream([
153
+ 'getSize' => function () { return null; },
154
+ 'tell' => function () { return 0; },
155
+ ]);
156
+ $b = new LimitStream($a);
157
+ $this->assertNull($b->getSize());
158
+ }
159
+
160
+ public function testLengthLessOffsetWhenNoLimitSize()
161
+ {
162
+ $a = Psr7\stream_for('foo_bar');
163
+ $b = new LimitStream($a, -1, 4);
164
+ $this->assertEquals(3, $b->getSize());
165
+ }
166
+ }
app/api/Ctct/vendor/guzzlehttp/psr7/tests/MultipartStreamTest.php ADDED
@@ -0,0 +1,214 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Tests;
3
+
4
+ use GuzzleHttp\Psr7;
5
+ use GuzzleHttp\Psr7\MultipartStream;
6
+
7
+ class MultipartStreamTest extends \PHPUnit_Framework_TestCase
8
+ {
9
+ public function testCreatesDefaultBoundary()
10
+ {
11
+ $b = new MultipartStream();
12
+ $this->assertNotEmpty($b->getBoundary());
13
+ }
14
+
15
+ public function testCanProvideBoundary()
16
+ {
17
+ $b = new MultipartStream([], 'foo');
18
+ $this->assertEquals('foo', $b->getBoundary());
19
+ }
20
+
21
+ public function testIsNotWritable()
22
+ {
23
+ $b = new MultipartStream();
24
+ $this->assertFalse($b->isWritable());
25
+ }
26
+
27
+ public function testCanCreateEmptyStream()
28
+ {
29
+ $b = new MultipartStream();
30
+ $boundary = $b->getBoundary();
31
+ $this->assertSame("--{$boundary}--\r\n", $b->getContents());
32
+ $this->assertSame(strlen($boundary) + 6, $b->getSize());
33
+ }
34
+
35
+ /**
36
+ * @expectedException \InvalidArgumentException
37
+ */
38
+ public function testValidatesFilesArrayElement()
39
+ {
40
+ new MultipartStream([['foo' => 'bar']]);
41
+ }
42
+
43
+ /**
44
+ * @expectedException \InvalidArgumentException
45
+ */
46
+ public function testEnsuresFileHasName()
47
+ {
48
+ new MultipartStream([['contents' => 'bar']]);
49
+ }
50
+
51
+ public function testSerializesFields()
52
+ {
53
+ $b = new MultipartStream([
54
+ [
55
+ 'name' => 'foo',
56
+ 'contents' => 'bar'
57
+ ],
58
+ [
59
+ 'name' => 'baz',
60
+ 'contents' => 'bam'
61
+ ]
62
+ ], 'boundary');
63
+ $this->assertEquals(
64
+ "--boundary\r\nContent-Disposition: form-data; name=\"foo\"\r\nContent-Length: 3\r\n\r\n"
65
+ . "bar\r\n--boundary\r\nContent-Disposition: form-data; name=\"baz\"\r\nContent-Length: 3"
66
+ . "\r\n\r\nbam\r\n--boundary--\r\n", (string) $b);
67
+ }
68
+
69
+ public function testSerializesFiles()
70
+ {
71
+ $f1 = Psr7\FnStream::decorate(Psr7\stream_for('foo'), [
72
+ 'getMetadata' => function () {
73
+ return '/foo/bar.txt';
74
+ }
75
+ ]);
76
+
77
+ $f2 = Psr7\FnStream::decorate(Psr7\stream_for('baz'), [
78
+ 'getMetadata' => function () {
79
+ return '/foo/baz.jpg';
80
+ }
81
+ ]);
82
+
83
+ $f3 = Psr7\FnStream::decorate(Psr7\stream_for('bar'), [
84
+ 'getMetadata' => function () {
85
+ return '/foo/bar.gif';
86
+ }
87
+ ]);
88
+
89
+ $b = new MultipartStream([
90
+ [
91
+ 'name' => 'foo',
92
+ 'contents' => $f1
93
+ ],
94
+ [
95
+ 'name' => 'qux',
96
+ 'contents' => $f2
97
+ ],
98
+ [
99
+ 'name' => 'qux',
100
+ 'contents' => $f3
101
+ ],
102
+ ], 'boundary');
103
+
104
+ $expected = <<<EOT
105
+ --boundary
106
+ Content-Disposition: form-data; name="foo"; filename="bar.txt"
107
+ Content-Length: 3
108
+ Content-Type: text/plain
109
+
110
+ foo
111
+ --boundary
112
+ Content-Disposition: form-data; name="qux"; filename="baz.jpg"
113
+ Content-Length: 3
114
+ Content-Type: image/jpeg
115
+
116
+ baz
117
+ --boundary
118
+ Content-Disposition: form-data; name="qux"; filename="bar.gif"
119
+ Content-Length: 3
120
+ Content-Type: image/gif
121
+
122
+ bar
123
+ --boundary--
124
+
125
+ EOT;
126
+
127
+ $this->assertEquals($expected, str_replace("\r", '', $b));
128
+ }
129
+
130
+ public function testSerializesFilesWithCustomHeaders()
131
+ {
132
+ $f1 = Psr7\FnStream::decorate(Psr7\stream_for('foo'), [
133
+ 'getMetadata' => function () {
134
+ return '/foo/bar.txt';
135
+ }
136
+ ]);
137
+
138
+ $b = new MultipartStream([
139
+ [
140
+ 'name' => 'foo',
141
+ 'contents' => $f1,
142
+ 'headers' => [
143
+ 'x-foo' => 'bar',
144
+ 'content-disposition' => 'custom'
145
+ ]
146
+ ]
147
+ ], 'boundary');
148
+
149
+ $expected = <<<EOT
150
+ --boundary
151
+ x-foo: bar
152
+ content-disposition: custom
153
+ Content-Length: 3
154
+ Content-Type: text/plain
155
+
156
+ foo
157
+ --boundary--
158
+
159
+ EOT;
160
+
161
+ $this->assertEquals($expected, str_replace("\r", '', $b));
162
+ }
163
+
164
+ public function testSerializesFilesWithCustomHeadersAndMultipleValues()
165
+ {
166
+ $f1 = Psr7\FnStream::decorate(Psr7\stream_for('foo'), [
167
+ 'getMetadata' => function () {
168
+ return '/foo/bar.txt';
169
+ }
170
+ ]);
171
+
172
+ $f2 = Psr7\FnStream::decorate(Psr7\stream_for('baz'), [
173
+ 'getMetadata' => function () {
174
+ return '/foo/baz.jpg';
175
+ }
176
+ ]);
177
+
178
+ $b = new MultipartStream([
179
+ [
180
+ 'name' => 'foo',
181
+ 'contents' => $f1,
182
+ 'headers' => [
183
+ 'x-foo' => 'bar',
184
+ 'content-disposition' => 'custom'
185
+ ]
186
+ ],
187
+ [
188
+ 'name' => 'foo',
189
+ 'contents' => $f2,
190
+ 'headers' => ['cOntenT-Type' => 'custom'],
191
+ ]
192
+ ], 'boundary');
193
+
194
+ $expected = <<<EOT
195
+ --boundary
196
+ x-foo: bar
197
+ content-disposition: custom
198
+ Content-Length: 3
199
+ Content-Type: text/plain
200
+
201
+ foo
202
+ --boundary
203
+ cOntenT-Type: custom
204
+ Content-Disposition: form-data; name="foo"; filename="baz.jpg"
205
+ Content-Length: 3
206
+
207
+ baz
208
+ --boundary--
209
+
210
+ EOT;
211
+
212
+ $this->assertEquals($expected, str_replace("\r", '', $b));
213
+ }
214
+ }
app/api/Ctct/vendor/guzzlehttp/psr7/tests/NoSeekStreamTest.php ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Tests\Psr7;
3
+
4
+ use GuzzleHttp\Psr7;
5
+ use GuzzleHttp\Psr7\NoSeekStream;
6
+
7
+ /**
8
+ * @covers GuzzleHttp\Psr7\NoSeekStream
9
+ * @covers GuzzleHttp\Psr7\StreamDecoratorTrait
10
+ */
11
+ class NoSeekStreamTest extends \PHPUnit_Framework_TestCase
12
+ {
13
+ /**
14
+ * @expectedException \RuntimeException
15
+ * @expectedExceptionMessage Cannot seek a NoSeekStream
16
+ */
17
+ public function testCannotSeek()
18
+ {
19
+ $s = $this->getMockBuilder('Psr\Http\Message\StreamInterface')
20
+ ->setMethods(['isSeekable', 'seek'])
21
+ ->getMockForAbstractClass();
22
+ $s->expects($this->never())->method('seek');
23
+ $s->expects($this->never())->method('isSeekable');
24
+ $wrapped = new NoSeekStream($s);
25
+ $this->assertFalse($wrapped->isSeekable());
26
+ $wrapped->seek(2);
27
+ }
28
+
29
+ /**
30
+ * @expectedException \RuntimeException
31
+ * @expectedExceptionMessage Cannot write to a non-writable stream
32
+ */
33
+ public function testHandlesClose()
34
+ {
35
+ $s = Psr7\stream_for('foo');
36
+ $wrapped = new NoSeekStream($s);
37
+ $wrapped->close();
38
+ $wrapped->write('foo');
39
+ }
40
+ }
app/api/Ctct/vendor/guzzlehttp/psr7/tests/PumpStreamTest.php ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Tests\Psr7;
3
+
4
+ use GuzzleHttp\Psr7\LimitStream;
5
+ use GuzzleHttp\Psr7\PumpStream;
6
+ use GuzzleHttp\Psr7;
7
+
8
+ class PumpStreamTest extends \PHPUnit_Framework_TestCase
9
+ {
10
+ public function testHasMetadataAndSize()
11
+ {
12
+ $p = new PumpStream(function () {}, [
13
+ 'metadata' => ['foo' => 'bar'],
14
+ 'size' => 100
15
+ ]);
16
+
17
+ $this->assertEquals('bar', $p->getMetadata('foo'));
18
+ $this->assertEquals(['foo' => 'bar'], $p->getMetadata());
19
+ $this->assertEquals(100, $p->getSize());
20
+ }
21
+
22
+ public function testCanReadFromCallable()
23
+ {
24
+ $p = Psr7\stream_for(function ($size) {
25
+ return 'a';
26
+ });
27
+ $this->assertEquals('a', $p->read(1));
28
+ $this->assertEquals(1, $p->tell());
29
+ $this->assertEquals('aaaaa', $p->read(5));
30
+ $this->assertEquals(6, $p->tell());
31
+ }
32
+
33
+ public function testStoresExcessDataInBuffer()
34
+ {
35
+ $called = [];
36
+ $p = Psr7\stream_for(function ($size) use (&$called) {
37
+ $called[] = $size;
38
+ return 'abcdef';
39
+ });
40
+ $this->assertEquals('a', $p->read(1));
41
+ $this->assertEquals('b', $p->read(1));
42
+ $this->assertEquals('cdef', $p->read(4));
43
+ $this->assertEquals('abcdefabc', $p->read(9));
44
+ $this->assertEquals([1, 9, 3], $called);
45
+ }
46
+
47
+ public function testInifiniteStreamWrappedInLimitStream()
48
+ {
49
+ $p = Psr7\stream_for(function () { return 'a'; });
50
+ $s = new LimitStream($p, 5);
51
+ $this->assertEquals('aaaaa', (string) $s);
52
+ }
53
+
54
+ public function testDescribesCapabilities()
55
+ {
56
+ $p = Psr7\stream_for(function () {});
57
+ $this->assertTrue($p->isReadable());
58
+ $this->assertFalse($p->isSeekable());
59
+ $this->assertFalse($p->isWritable());
60
+ $this->assertNull($p->getSize());
61
+ $this->assertEquals('', $p->getContents());
62
+ $this->assertEquals('', (string) $p);
63
+ $p->close();
64
+ $this->assertEquals('', $p->read(10));
65
+ $this->assertTrue($p->eof());
66
+
67
+ try {
68
+ $this->assertFalse($p->write('aa'));
69
+ $this->fail();
70
+ } catch (\RuntimeException $e) {}
71
+ }
72
+ }
app/api/Ctct/vendor/guzzlehttp/psr7/tests/RequestTest.php ADDED
@@ -0,0 +1,157 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Tests\Psr7;
3
+
4
+ use GuzzleHttp\Psr7\Request;
5
+ use GuzzleHttp\Psr7\Uri;
6
+
7
+ /**
8
+ * @covers GuzzleHttp\Psr7\Request
9
+ */
10
+ class RequestTest extends \PHPUnit_Framework_TestCase
11
+ {
12
+ public function testRequestUriMayBeString()
13
+ {
14
+ $r = new Request('GET', '/');
15
+ $this->assertEquals('/', (string) $r->getUri());
16
+ }
17
+
18
+ public function testRequestUriMayBeUri()
19
+ {
20
+ $uri = new Uri('/');
21
+ $r = new Request('GET', $uri);
22
+ $this->assertSame($uri, $r->getUri());
23
+ }
24
+
25
+ /**
26
+ * @expectedException \InvalidArgumentException
27
+ */
28
+ public function testValidateRequestUri()
29
+ {
30
+ new Request('GET', true);
31
+ }
32
+
33
+ public function testCanConstructWithBody()
34
+ {
35
+ $r = new Request('GET', '/', [], 'baz');
36
+ $this->assertEquals('baz', (string) $r->getBody());
37
+ }
38
+
39
+ public function testCapitalizesMethod()
40
+ {
41
+ $r = new Request('get', '/');
42
+ $this->assertEquals('GET', $r->getMethod());
43
+ }
44
+
45
+ public function testCapitalizesWithMethod()
46
+ {
47
+ $r = new Request('GET', '/');
48
+ $this->assertEquals('PUT', $r->withMethod('put')->getMethod());
49
+ }
50
+
51
+ public function testWithUri()
52
+ {
53
+ $r1 = new Request('GET', '/');
54
+ $u1 = $r1->getUri();
55
+ $u2 = new Uri('http://www.example.com');
56
+ $r2 = $r1->withUri($u2);
57
+ $this->assertNotSame($r1, $r2);
58
+ $this->assertSame($u2, $r2->getUri());
59
+ $this->assertSame($u1, $r1->getUri());
60
+ }
61
+
62
+ public function testSameInstanceWhenSameUri()
63
+ {
64
+ $r1 = new Request('GET', 'http://foo.com');
65
+ $r2 = $r1->withUri($r1->getUri());
66
+ $this->assertSame($r1, $r2);
67
+ }
68
+
69
+ public function testWithRequestTarget()
70
+ {
71
+ $r1 = new Request('GET', '/');
72
+ $r2 = $r1->withRequestTarget('*');
73
+ $this->assertEquals('*', $r2->getRequestTarget());
74
+ $this->assertEquals('/', $r1->getRequestTarget());
75
+ }
76
+
77
+ /**
78
+ * @expectedException \InvalidArgumentException
79
+ */
80
+ public function testRequestTargetDoesNotAllowSpaces()
81
+ {
82
+ $r1 = new Request('GET', '/');
83
+ $r1->withRequestTarget('/foo bar');
84
+ }
85
+
86
+ public function testRequestTargetDefaultsToSlash()
87
+ {
88
+ $r1 = new Request('GET', '');
89
+ $this->assertEquals('/', $r1->getRequestTarget());
90
+ $r2 = new Request('GET', '*');
91
+ $this->assertEquals('*', $r2->getRequestTarget());
92
+ $r3 = new Request('GET', 'http://foo.com/bar baz/');
93
+ $this->assertEquals('/bar%20baz/', $r3->getRequestTarget());
94
+ }
95
+
96
+ public function testBuildsRequestTarget()
97
+ {
98
+ $r1 = new Request('GET', 'http://foo.com/baz?bar=bam');
99
+ $this->assertEquals('/baz?bar=bam', $r1->getRequestTarget());
100
+ }
101
+
102
+ public function testHostIsAddedFirst()
103
+ {
104
+ $r = new Request('GET', 'http://foo.com/baz?bar=bam', ['Foo' => 'Bar']);
105
+ $this->assertEquals([
106
+ 'Host' => ['foo.com'],
107
+ 'Foo' => ['Bar']
108
+ ], $r->getHeaders());
109
+ }
110
+
111
+ public function testCanGetHeaderAsCsv()
112
+ {
113
+ $r = new Request('GET', 'http://foo.com/baz?bar=bam', [
114
+ 'Foo' => ['a', 'b', 'c']
115
+ ]);
116
+ $this->assertEquals('a, b, c', $r->getHeaderLine('Foo'));
117
+ $this->assertEquals('', $r->getHeaderLine('Bar'));
118
+ }
119
+
120
+ public function testHostIsNotOverwrittenWhenPreservingHost()
121
+ {
122
+ $r = new Request('GET', 'http://foo.com/baz?bar=bam', ['Host' => 'a.com']);
123
+ $this->assertEquals(['Host' => ['a.com']], $r->getHeaders());
124
+ $r2 = $r->withUri(new Uri('http://www.foo.com/bar'), true);
125
+ $this->assertEquals('a.com', $r2->getHeaderLine('Host'));
126
+ }
127
+
128
+ public function testOverridesHostWithUri()
129
+ {
130
+ $r = new Request('GET', 'http://foo.com/baz?bar=bam');
131
+ $this->assertEquals(['Host' => ['foo.com']], $r->getHeaders());
132
+ $r2 = $r->withUri(new Uri('http://www.baz.com/bar'));
133
+ $this->assertEquals('www.baz.com', $r2->getHeaderLine('Host'));
134
+ }
135
+
136
+ public function testAggregatesHeaders()
137
+ {
138
+ $r = new Request('GET', 'http://foo.com', [
139
+ 'ZOO' => 'zoobar',
140
+ 'zoo' => ['foobar', 'zoobar']
141
+ ]);
142
+ $this->assertEquals('zoobar, foobar, zoobar', $r->getHeaderLine('zoo'));
143
+ }
144
+
145
+ public function testAddsPortToHeader()
146
+ {
147
+ $r = new Request('GET', 'http://foo.com:8124/bar');
148
+ $this->assertEquals('foo.com:8124', $r->getHeaderLine('host'));
149
+ }
150
+
151
+ public function testAddsPortToHeaderAndReplacePreviousPort()
152
+ {
153
+ $r = new Request('GET', 'http://foo.com:8124/bar');
154
+ $r = $r->withUri(new Uri('http://foo.com:8125/bar'));
155
+ $this->assertEquals('foo.com:8125', $r->getHeaderLine('host'));
156
+ }
157
+ }
app/api/Ctct/vendor/guzzlehttp/psr7/tests/ResponseTest.php ADDED
@@ -0,0 +1,146 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Tests\Psr7;
3
+
4
+ use GuzzleHttp\Psr7\Response;
5
+ use GuzzleHttp\Psr7;
6
+
7
+ /**
8
+ * @covers GuzzleHttp\Psr7\MessageTrait
9
+ * @covers GuzzleHttp\Psr7\Response
10
+ */
11
+ class ResponseTest extends \PHPUnit_Framework_TestCase
12
+ {
13
+ public function testAddsDefaultReason()
14
+ {
15
+ $r = new Response('200');
16
+ $this->assertSame(200, $r->getStatusCode());
17
+ $this->assertEquals('OK', $r->getReasonPhrase());
18
+ }
19
+
20
+ public function testCanGiveCustomReason()
21
+ {
22
+ $r = new Response(200, [], null, '1.1', 'bar');
23
+ $this->assertEquals('bar', $r->getReasonPhrase());
24
+ }
25
+
26
+ public function testCanGiveCustomProtocolVersion()
27
+ {
28
+ $r = new Response(200, [], null, '1000');
29
+ $this->assertEquals('1000', $r->getProtocolVersion());
30
+ }
31
+
32
+ public function testCanCreateNewResponseWithStatusAndNoReason()
33
+ {
34
+ $r = new Response(200);
35
+ $r2 = $r->withStatus(201);
36
+ $this->assertEquals(200, $r->getStatusCode());
37
+ $this->assertEquals('OK', $r->getReasonPhrase());
38
+ $this->assertEquals(201, $r2->getStatusCode());
39
+ $this->assertEquals('Created', $r2->getReasonPhrase());
40
+ }
41
+
42
+ public function testCanCreateNewResponseWithStatusAndReason()
43
+ {
44
+ $r = new Response(200);
45
+ $r2 = $r->withStatus(201, 'Foo');
46
+ $this->assertEquals(200, $r->getStatusCode());
47
+ $this->assertEquals('OK', $r->getReasonPhrase());
48
+ $this->assertEquals(201, $r2->getStatusCode());
49
+ $this->assertEquals('Foo', $r2->getReasonPhrase());
50
+ }
51
+
52
+ public function testCreatesResponseWithAddedHeaderArray()
53
+ {
54
+ $r = new Response();
55
+ $r2 = $r->withAddedHeader('foo', ['baz', 'bar']);
56
+ $this->assertFalse($r->hasHeader('foo'));
57
+ $this->assertEquals('baz, bar', $r2->getHeaderLine('foo'));
58
+ }
59
+
60
+ public function testReturnsIdentityWhenRemovingMissingHeader()
61
+ {
62
+ $r = new Response();
63
+ $this->assertSame($r, $r->withoutHeader('foo'));
64
+ }
65
+
66
+ public function testAlwaysReturnsBody()
67
+ {
68
+ $r = new Response();
69
+ $this->assertInstanceOf('Psr\Http\Message\StreamInterface', $r->getBody());
70
+ }
71
+
72
+ public function testCanSetHeaderAsArray()
73
+ {
74
+ $r = new Response(200, [
75
+ 'foo' => ['baz ', ' bar ']
76
+ ]);
77
+ $this->assertEquals('baz, bar', $r->getHeaderLine('foo'));
78
+ $this->assertEquals(['baz', 'bar'], $r->getHeader('foo'));
79
+ }
80
+
81
+ public function testSameInstanceWhenSameBody()
82
+ {
83
+ $r = new Response(200, [], 'foo');
84
+ $b = $r->getBody();
85
+ $this->assertSame($r, $r->withBody($b));
86
+ }
87
+
88
+ public function testNewInstanceWhenNewBody()
89
+ {
90
+ $r = new Response(200, [], 'foo');
91
+ $b2 = Psr7\stream_for('abc');
92
+ $this->assertNotSame($r, $r->withBody($b2));
93
+ }
94
+
95
+ public function testSameInstanceWhenSameProtocol()
96
+ {
97
+ $r = new Response(200);
98
+ $this->assertSame($r, $r->withProtocolVersion('1.1'));
99
+ }
100
+
101
+ public function testNewInstanceWhenNewProtocol()
102
+ {
103
+ $r = new Response(200);
104
+ $this->assertNotSame($r, $r->withProtocolVersion('1.0'));
105
+ }
106
+
107
+ public function testNewInstanceWhenRemovingHeader()
108
+ {
109
+ $r = new Response(200, ['Foo' => 'Bar']);
110
+ $r2 = $r->withoutHeader('Foo');
111
+ $this->assertNotSame($r, $r2);
112
+ $this->assertFalse($r2->hasHeader('foo'));
113
+ }
114
+
115
+ public function testNewInstanceWhenAddingHeader()
116
+ {
117
+ $r = new Response(200, ['Foo' => 'Bar']);
118
+ $r2 = $r->withAddedHeader('Foo', 'Baz');
119
+ $this->assertNotSame($r, $r2);
120
+ $this->assertEquals('Bar, Baz', $r2->getHeaderLine('foo'));
121
+ }
122
+
123
+ public function testNewInstanceWhenAddingHeaderThatWasNotThereBefore()
124
+ {
125
+ $r = new Response(200, ['Foo' => 'Bar']);
126
+ $r2 = $r->withAddedHeader('Baz', 'Bam');
127
+ $this->assertNotSame($r, $r2);
128
+ $this->assertEquals('Bam', $r2->getHeaderLine('Baz'));
129
+ $this->assertEquals('Bar', $r2->getHeaderLine('Foo'));
130
+ }
131
+
132
+ public function testRemovesPreviouslyAddedHeaderOfDifferentCase()
133
+ {
134
+ $r = new Response(200, ['Foo' => 'Bar']);
135
+ $r2 = $r->withHeader('foo', 'Bam');
136
+ $this->assertNotSame($r, $r2);
137
+ $this->assertEquals('Bam', $r2->getHeaderLine('Foo'));
138
+ }
139
+
140
+ public function testBodyConsistent()
141
+ {
142
+ $r = new Response(200, [], '0');
143
+ $this->assertEquals('0', (string)$r->getBody());
144
+ }
145
+
146
+ }
app/api/Ctct/vendor/guzzlehttp/psr7/tests/StreamDecoratorTraitTest.php ADDED
@@ -0,0 +1,137 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Tests\Psr7;
3
+
4
+ use Psr\Http\Message\StreamInterface;
5
+ use GuzzleHttp\Psr7;
6
+ use GuzzleHttp\Psr7\StreamDecoratorTrait;
7
+
8
+ class Str implements StreamInterface
9
+ {
10
+ use StreamDecoratorTrait;
11
+ }
12
+
13
+ /**
14
+ * @covers GuzzleHttp\Psr7\StreamDecoratorTrait
15
+ */
16
+ class StreamDecoratorTraitTest extends \PHPUnit_Framework_TestCase
17
+ {
18
+ private $a;
19
+ private $b;
20
+ private $c;
21
+
22
+ public function setUp()
23
+ {
24
+ $this->c = fopen('php://temp', 'r+');
25
+ fwrite($this->c, 'foo');
26
+ fseek($this->c, 0);
27
+ $this->a = Psr7\stream_for($this->c);
28
+ $this->b = new Str($this->a);
29
+ }
30
+
31
+ public function testCatchesExceptionsWhenCastingToString()
32
+ {
33
+ $s = $this->getMockBuilder('Psr\Http\Message\StreamInterface')
34
+ ->setMethods(['read'])
35
+ ->getMockForAbstractClass();
36
+ $s->expects($this->once())
37
+ ->method('read')
38
+ ->will($this->throwException(new \Exception('foo')));
39
+ $msg = '';
40
+ set_error_handler(function ($errNo, $str) use (&$msg) { $msg = $str; });
41
+ echo new Str($s);
42
+ restore_error_handler();
43
+ $this->assertContains('foo', $msg);
44
+ }
45
+
46
+ public function testToString()
47
+ {
48
+ $this->assertEquals('foo', (string) $this->b);
49
+ }
50
+
51
+ public function testHasSize()
52
+ {
53
+ $this->assertEquals(3, $this->b->getSize());
54
+ }
55
+
56
+ public function testReads()
57
+ {
58
+ $this->assertEquals('foo', $this->b->read(10));
59
+ }
60
+
61
+ public function testCheckMethods()
62
+ {
63
+ $this->assertEquals($this->a->isReadable(), $this->b->isReadable());
64
+ $this->assertEquals($this->a->isWritable(), $this->b->isWritable());
65
+ $this->assertEquals($this->a->isSeekable(), $this->b->isSeekable());
66
+ }
67
+
68
+ public function testSeeksAndTells()
69
+ {
70
+ $this->b->seek(1);
71
+ $this->assertEquals(1, $this->a->tell());
72
+ $this->assertEquals(1, $this->b->tell());
73
+ $this->b->seek(0);
74
+ $this->assertEquals(0, $this->a->tell());
75
+ $this->assertEquals(0, $this->b->tell());
76
+ $this->b->seek(0, SEEK_END);
77
+ $this->assertEquals(3, $this->a->tell());
78
+ $this->assertEquals(3, $this->b->tell());
79
+ }
80
+
81
+ public function testGetsContents()
82
+ {
83
+ $this->assertEquals('foo', $this->b->getContents());
84
+ $this->assertEquals('', $this->b->getContents());
85
+ $this->b->seek(1);
86
+ $this->assertEquals('oo', $this->b->getContents(1));
87
+ }
88
+
89
+ public function testCloses()
90
+ {
91
+ $this->b->close();
92
+ $this->assertFalse(is_resource($this->c));
93
+ }
94
+
95
+ public function testDetaches()
96
+ {
97
+ $this->b->detach();
98
+ $this->assertFalse($this->b->isReadable());
99
+ }
100
+
101
+ public function testWrapsMetadata()
102
+ {
103
+ $this->assertSame($this->b->getMetadata(), $this->a->getMetadata());
104
+ $this->assertSame($this->b->getMetadata('uri'), $this->a->getMetadata('uri'));
105
+ }
106
+
107
+ public function testWrapsWrites()
108
+ {
109
+ $this->b->seek(0, SEEK_END);
110
+ $this->b->write('foo');
111
+ $this->assertEquals('foofoo', (string) $this->a);
112
+ }
113
+
114
+ /**
115
+ * @expectedException \UnexpectedValueException
116
+ */
117
+ public function testThrowsWithInvalidGetter()
118
+ {
119
+ $this->b->foo;
120
+ }
121
+
122
+ /**
123
+ * @expectedException \BadMethodCallException
124
+ */
125
+ public function testThrowsWhenGetterNotImplemented()
126
+ {
127
+ $s = new BadStream();
128
+ $s->stream;
129
+ }
130
+ }
131
+
132
+ class BadStream
133
+ {
134
+ use StreamDecoratorTrait;
135
+
136
+ public function __construct() {}
137
+ }
app/api/Ctct/vendor/guzzlehttp/psr7/tests/StreamTest.php ADDED
@@ -0,0 +1,161 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Tests\Psr7;
3
+
4
+ use GuzzleHttp\Psr7\NoSeekStream;
5
+ use GuzzleHttp\Psr7\Stream;
6
+
7
+ /**
8
+ * @covers GuzzleHttp\Psr7\Stream
9
+ */
10
+ class StreamTest extends \PHPUnit_Framework_TestCase
11
+ {
12
+ /**
13
+ * @expectedException \InvalidArgumentException
14
+ */
15
+ public function testConstructorThrowsExceptionOnInvalidArgument()
16
+ {
17
+ new Stream(true);
18
+ }
19
+
20
+ public function testConstructorInitializesProperties()
21
+ {
22
+ $handle = fopen('php://temp', 'r+');
23
+ fwrite($handle, 'data');
24
+ $stream = new Stream($handle);
25
+ $this->assertTrue($stream->isReadable());
26
+ $this->assertTrue($stream->isWritable());
27
+ $this->assertTrue($stream->isSeekable());
28
+ $this->assertEquals('php://temp', $stream->getMetadata('uri'));
29
+ $this->assertInternalType('array', $stream->getMetadata());
30
+ $this->assertEquals(4, $stream->getSize());
31
+ $this->assertFalse($stream->eof());
32
+ $stream->close();
33
+ }
34
+
35
+ public function testStreamClosesHandleOnDestruct()
36
+ {
37
+ $handle = fopen('php://temp', 'r');
38
+ $stream = new Stream($handle);
39
+ unset($stream);
40
+ $this->assertFalse(is_resource($handle));
41
+ }
42
+
43
+ public function testConvertsToString()
44
+ {
45
+ $handle = fopen('php://temp', 'w+');
46
+ fwrite($handle, 'data');
47
+ $stream = new Stream($handle);
48
+ $this->assertEquals('data', (string) $stream);
49
+ $this->assertEquals('data', (string) $stream);
50
+ $stream->close();
51
+ }
52
+
53
+ public function testGetsContents()
54
+ {
55
+ $handle = fopen('php://temp', 'w+');
56
+ fwrite($handle, 'data');
57
+ $stream = new Stream($handle);
58
+ $this->assertEquals('', $stream->getContents());
59
+ $stream->seek(0);
60
+ $this->assertEquals('data', $stream->getContents());
61
+ $this->assertEquals('', $stream->getContents());
62
+ }
63
+
64
+ public function testChecksEof()
65
+ {
66
+ $handle = fopen('php://temp', 'w+');
67
+ fwrite($handle, 'data');
68
+ $stream = new Stream($handle);
69
+ $this->assertFalse($stream->eof());
70
+ $stream->read(4);
71
+ $this->assertTrue($stream->eof());
72
+ $stream->close();
73
+ }
74
+
75
+ public function testGetSize()
76
+ {
77
+ $size = filesize(__FILE__);
78
+ $handle = fopen(__FILE__, 'r');
79
+ $stream = new Stream($handle);
80
+ $this->assertEquals($size, $stream->getSize());
81
+ // Load from cache
82
+ $this->assertEquals($size, $stream->getSize());
83
+ $stream->close();
84
+ }
85
+
86
+ public function testEnsuresSizeIsConsistent()
87
+ {
88
+ $h = fopen('php://temp', 'w+');
89
+ $this->assertEquals(3, fwrite($h, 'foo'));
90
+ $stream = new Stream($h);
91
+ $this->assertEquals(3, $stream->getSize());
92
+ $this->assertEquals(4, $stream->write('test'));
93
+ $this->assertEquals(7, $stream->getSize());
94
+ $this->assertEquals(7, $stream->getSize());
95
+ $stream->close();
96
+ }
97
+
98
+ public function testProvidesStreamPosition()
99
+ {
100
+ $handle = fopen('php://temp', 'w+');
101
+ $stream = new Stream($handle);
102
+ $this->assertEquals(0, $stream->tell());
103
+ $stream->write('foo');
104
+ $this->assertEquals(3, $stream->tell());
105
+ $stream->seek(1);
106
+ $this->assertEquals(1, $stream->tell());
107
+ $this->assertSame(ftell($handle), $stream->tell());
108
+ $stream->close();
109
+ }
110
+
111
+ public function testCanDetachStream()
112
+ {
113
+ $r = fopen('php://temp', 'w+');
114
+ $stream = new Stream($r);
115
+ $stream->write('foo');
116
+ $this->assertTrue($stream->isReadable());
117
+ $this->assertSame($r, $stream->detach());
118
+ $stream->detach();
119
+
120
+ $this->assertFalse($stream->isReadable());
121
+ $this->assertFalse($stream->isWritable());
122
+ $this->assertFalse($stream->isSeekable());
123
+
124
+ $throws = function (callable $fn) use ($stream) {
125
+ try {
126
+ $fn($stream);
127
+ $this->fail();
128
+ } catch (\Exception $e) {}
129
+ };
130
+
131
+ $throws(function ($stream) { $stream->read(10); });
132
+ $throws(function ($stream) { $stream->write('bar'); });
133
+ $throws(function ($stream) { $stream->seek(10); });
134
+ $throws(function ($stream) { $stream->tell(); });
135
+ $throws(function ($stream) { $stream->eof(); });
136
+ $throws(function ($stream) { $stream->getSize(); });
137
+ $throws(function ($stream) { $stream->getContents(); });
138
+ $this->assertSame('', (string) $stream);
139
+ $stream->close();
140
+ }
141
+
142
+ public function testCloseClearProperties()
143
+ {
144
+ $handle = fopen('php://temp', 'r+');
145
+ $stream = new Stream($handle);
146
+ $stream->close();
147
+
148
+ $this->assertFalse($stream->isSeekable());
149
+ $this->assertFalse($stream->isReadable());
150
+ $this->assertFalse($stream->isWritable());
151
+ $this->assertNull($stream->getSize());
152
+ $this->assertEmpty($stream->getMetadata());
153
+ }
154
+
155
+ public function testDoesNotThrowInToString()
156
+ {
157
+ $s = \GuzzleHttp\Psr7\stream_for('foo');
158
+ $s = new NoSeekStream($s);
159
+ $this->assertEquals('foo', (string) $s);
160
+ }
161
+ }
app/api/Ctct/vendor/guzzlehttp/psr7/tests/StreamWrapperTest.php ADDED
@@ -0,0 +1,100 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Tests\Psr7;
3
+
4
+ use GuzzleHttp\Psr7\StreamWrapper;
5
+ use GuzzleHttp\Psr7;
6
+
7
+ /**
8
+ * @covers GuzzleHttp\Psr7\StreamWrapper
9
+ */
10
+ class StreamWrapperTest extends \PHPUnit_Framework_TestCase
11
+ {
12
+ public function testResource()
13
+ {
14
+ $stream = Psr7\stream_for('foo');
15
+ $handle = StreamWrapper::getResource($stream);
16
+ $this->assertSame('foo', fread($handle, 3));
17
+ $this->assertSame(3, ftell($handle));
18
+ $this->assertSame(3, fwrite($handle, 'bar'));
19
+ $this->assertSame(0, fseek($handle, 0));
20
+ $this->assertSame('foobar', fread($handle, 6));
21
+ $this->assertSame('', fread($handle, 1));
22
+ $this->assertTrue(feof($handle));
23
+
24
+ // This fails on HHVM for some reason
25
+ if (!defined('HHVM_VERSION')) {
26
+ $this->assertEquals([
27
+ 'dev' => 0,
28
+ 'ino' => 0,
29
+ 'mode' => 33206,
30
+ 'nlink' => 0,
31
+ 'uid' => 0,
32
+ 'gid' => 0,
33
+ 'rdev' => 0,
34
+ 'size' => 6,
35
+ 'atime' => 0,
36
+ 'mtime' => 0,
37
+ 'ctime' => 0,
38
+ 'blksize' => 0,
39
+ 'blocks' => 0,
40
+ 0 => 0,
41
+ 1 => 0,
42
+ 2 => 33206,
43
+ 3 => 0,
44
+ 4 => 0,
45
+ 5 => 0,
46
+ 6 => 0,
47
+ 7 => 6,
48
+ 8 => 0,
49
+ 9 => 0,
50
+ 10 => 0,
51
+ 11 => 0,
52
+ 12 => 0,
53
+ ], fstat($handle));
54
+ }
55
+
56
+ $this->assertTrue(fclose($handle));
57
+ $this->assertSame('foobar', (string) $stream);
58
+ }
59
+
60
+ /**
61
+ * @expectedException \InvalidArgumentException
62
+ */
63
+ public function testValidatesStream()
64
+ {
65
+ $stream = $this->getMockBuilder('Psr\Http\Message\StreamInterface')
66
+ ->setMethods(['isReadable', 'isWritable'])
67
+ ->getMockForAbstractClass();
68
+ $stream->expects($this->once())
69
+ ->method('isReadable')
70
+ ->will($this->returnValue(false));
71
+ $stream->expects($this->once())
72
+ ->method('isWritable')
73
+ ->will($this->returnValue(false));
74
+ StreamWrapper::getResource($stream);
75
+ }
76
+
77
+ /**
78
+ * @expectedException \PHPUnit_Framework_Error_Warning
79
+ */
80
+ public function testReturnsFalseWhenStreamDoesNotExist()
81
+ {
82
+ fopen('guzzle://foo', 'r');
83
+ }
84
+
85
+ public function testCanOpenReadonlyStream()
86
+ {
87
+ $stream = $this->getMockBuilder('Psr\Http\Message\StreamInterface')
88
+ ->setMethods(['isReadable', 'isWritable'])
89
+ ->getMockForAbstractClass();
90
+ $stream->expects($this->once())
91
+ ->method('isReadable')
92
+ ->will($this->returnValue(false));
93
+ $stream->expects($this->once())
94
+ ->method('isWritable')
95
+ ->will($this->returnValue(true));
96
+ $r = StreamWrapper::getResource($stream);
97
+ $this->assertInternalType('resource', $r);
98
+ fclose($r);
99
+ }
100
+ }
app/api/Ctct/vendor/guzzlehttp/psr7/tests/UriTest.php ADDED
@@ -0,0 +1,281 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Tests\Psr7;
3
+
4
+ use GuzzleHttp\Psr7\Uri;
5
+
6
+ /**
7
+ * @covers GuzzleHttp\Psr7\Uri
8
+ */
9
+ class UriTest extends \PHPUnit_Framework_TestCase
10
+ {
11
+ const RFC3986_BASE = "http://a/b/c/d;p?q";
12
+
13
+ public function testParsesProvidedUrl()
14
+ {
15
+ $uri = new Uri('https://michael:test@test.com:443/path/123?q=abc#test');
16
+
17
+ // Standard port 443 for https gets ignored.
18
+ $this->assertEquals(
19
+ 'https://michael:test@test.com/path/123?q=abc#test',
20
+ (string) $uri
21
+ );
22
+
23
+ $this->assertEquals('test', $uri->getFragment());
24
+ $this->assertEquals('test.com', $uri->getHost());
25
+ $this->assertEquals('/path/123', $uri->getPath());
26
+ $this->assertEquals(null, $uri->getPort());
27
+ $this->assertEquals('q=abc', $uri->getQuery());
28
+ $this->assertEquals('https', $uri->getScheme());
29
+ $this->assertEquals('michael:test', $uri->getUserInfo());
30
+ }
31
+
32
+ /**
33
+ * @expectedException \InvalidArgumentException
34
+ * @expectedExceptionMessage Unable to parse URI
35
+ */
36
+ public function testValidatesUriCanBeParsed()
37
+ {
38
+ new Uri('///');
39
+ }
40
+
41
+ public function testCanTransformAndRetrievePartsIndividually()
42
+ {
43
+ $uri = (new Uri(''))
44
+ ->withFragment('#test')
45
+ ->withHost('example.com')
46
+ ->withPath('path/123')
47
+ ->withPort(8080)
48
+ ->withQuery('?q=abc')
49
+ ->withScheme('http')
50
+ ->withUserInfo('user', 'pass');
51
+
52
+ // Test getters.
53
+ $this->assertEquals('user:pass@example.com:8080', $uri->getAuthority());
54
+ $this->assertEquals('test', $uri->getFragment());
55
+ $this->assertEquals('example.com', $uri->getHost());
56
+ $this->assertEquals('path/123', $uri->getPath());
57
+ $this->assertEquals(8080, $uri->getPort());
58
+ $this->assertEquals('q=abc', $uri->getQuery());
59
+ $this->assertEquals('http', $uri->getScheme());
60
+ $this->assertEquals('user:pass', $uri->getUserInfo());
61
+ }
62
+
63
+ /**
64
+ * @expectedException \InvalidArgumentException
65
+ */
66
+ public function testPortMustBeValid()
67
+ {
68
+ (new Uri(''))->withPort(100000);
69
+ }
70
+
71
+ /**
72
+ * @expectedException \InvalidArgumentException
73
+ */
74
+ public function testPathMustBeValid()
75
+ {
76
+ (new Uri(''))->withPath([]);
77
+ }
78
+
79
+ /**
80
+ * @expectedException \InvalidArgumentException
81
+ */
82
+ public function testQueryMustBeValid()
83
+ {
84
+ (new Uri(''))->withQuery(new \stdClass);
85
+ }
86
+
87
+ public function testAllowsFalseyUrlParts()
88
+ {
89
+ $url = new Uri('http://a:1/0?0#0');
90
+ $this->assertSame('a', $url->getHost());
91
+ $this->assertEquals(1, $url->getPort());
92
+ $this->assertSame('/0', $url->getPath());
93
+ $this->assertEquals('0', (string) $url->getQuery());
94
+ $this->assertSame('0', $url->getFragment());
95
+ $this->assertEquals('http://a:1/0?0#0', (string) $url);
96
+ $url = new Uri('');
97
+ $this->assertSame('', (string) $url);
98
+ $url = new Uri('0');
99
+ $this->assertSame('0', (string) $url);
100
+ $url = new Uri('/');
101
+ $this->assertSame('/', (string) $url);
102
+ }
103
+
104
+ /**
105
+ * @dataProvider getResolveTestCases
106
+ */
107
+ public function testResolvesUris($base, $rel, $expected)
108
+ {
109
+ $uri = new Uri($base);
110
+ $actual = Uri::resolve($uri, $rel);
111
+ $this->assertEquals($expected, (string) $actual);
112
+ }
113
+
114
+ public function getResolveTestCases()
115
+ {
116
+ return [
117
+ //[self::RFC3986_BASE, 'g:h', 'g:h'],
118
+ [self::RFC3986_BASE, 'g', 'http://a/b/c/g'],
119
+ [self::RFC3986_BASE, './g', 'http://a/b/c/g'],
120
+ [self::RFC3986_BASE, 'g/', 'http://a/b/c/g/'],
121
+ [self::RFC3986_BASE, '/g', 'http://a/g'],
122
+ [self::RFC3986_BASE, '//g', 'http://g'],
123
+ [self::RFC3986_BASE, '?y', 'http://a/b/c/d;p?y'],
124
+ [self::RFC3986_BASE, 'g?y', 'http://a/b/c/g?y'],
125
+ [self::RFC3986_BASE, '#s', 'http://a/b/c/d;p?q#s'],
126
+ [self::RFC3986_BASE, 'g#s', 'http://a/b/c/g#s'],
127
+ [self::RFC3986_BASE, 'g?y#s', 'http://a/b/c/g?y#s'],
128
+ [self::RFC3986_BASE, ';x', 'http://a/b/c/;x'],
129
+ [self::RFC3986_BASE, 'g;x', 'http://a/b/c/g;x'],
130
+ [self::RFC3986_BASE, 'g;x?y#s', 'http://a/b/c/g;x?y#s'],
131
+ [self::RFC3986_BASE, '', self::RFC3986_BASE],
132
+ [self::RFC3986_BASE, '.', 'http://a/b/c/'],
133
+ [self::RFC3986_BASE, './', 'http://a/b/c/'],
134
+ [self::RFC3986_BASE, '..', 'http://a/b/'],
135
+ [self::RFC3986_BASE, '../', 'http://a/b/'],
136
+ [self::RFC3986_BASE, '../g', 'http://a/b/g'],
137
+ [self::RFC3986_BASE, '../..', 'http://a/'],
138
+ [self::RFC3986_BASE, '../../', 'http://a/'],
139
+ [self::RFC3986_BASE, '../../g', 'http://a/g'],
140
+ [self::RFC3986_BASE, '../../../g', 'http://a/g'],
141
+ [self::RFC3986_BASE, '../../../../g', 'http://a/g'],
142
+ [self::RFC3986_BASE, '/./g', 'http://a/g'],
143
+ [self::RFC3986_BASE, '/../g', 'http://a/g'],
144
+ [self::RFC3986_BASE, 'g.', 'http://a/b/c/g.'],
145
+ [self::RFC3986_BASE, '.g', 'http://a/b/c/.g'],
146
+ [self::RFC3986_BASE, 'g..', 'http://a/b/c/g..'],
147
+ [self::RFC3986_BASE, '..g', 'http://a/b/c/..g'],
148
+ [self::RFC3986_BASE, './../g', 'http://a/b/g'],
149
+ [self::RFC3986_BASE, 'foo////g', 'http://a/b/c/foo////g'],
150
+ [self::RFC3986_BASE, './g/.', 'http://a/b/c/g/'],
151
+ [self::RFC3986_BASE, 'g/./h', 'http://a/b/c/g/h'],
152
+ [self::RFC3986_BASE, 'g/../h', 'http://a/b/c/h'],
153
+ [self::RFC3986_BASE, 'g;x=1/./y', 'http://a/b/c/g;x=1/y'],
154
+ [self::RFC3986_BASE, 'g;x=1/../y', 'http://a/b/c/y'],
155
+ ['http://u@a/b/c/d;p?q', '.', 'http://u@a/b/c/'],
156
+ ['http://u:p@a/b/c/d;p?q', '.', 'http://u:p@a/b/c/'],
157
+ //[self::RFC3986_BASE, 'http:g', 'http:g'],
158
+ ];
159
+ }
160
+
161
+ public function testAddAndRemoveQueryValues()
162
+ {
163
+ $uri = new Uri('http://foo.com/bar');
164
+ $uri = Uri::withQueryValue($uri, 'a', 'b');
165
+ $uri = Uri::withQueryValue($uri, 'c', 'd');
166
+ $uri = Uri::withQueryValue($uri, 'e', null);
167
+ $this->assertEquals('a=b&c=d&e', $uri->getQuery());
168
+
169
+ $uri = Uri::withoutQueryValue($uri, 'c');
170
+ $uri = Uri::withoutQueryValue($uri, 'e');
171
+ $this->assertEquals('a=b', $uri->getQuery());
172
+ $uri = Uri::withoutQueryValue($uri, 'a');
173
+ $uri = Uri::withoutQueryValue($uri, 'a');
174
+ $this->assertEquals('', $uri->getQuery());
175
+ }
176
+
177
+ public function testGetAuthorityReturnsCorrectPort()
178
+ {
179
+ // HTTPS non-standard port
180
+ $uri = new Uri('https://foo.co:99');
181
+ $this->assertEquals('foo.co:99', $uri->getAuthority());
182
+
183
+ // HTTP non-standard port
184
+ $uri = new Uri('http://foo.co:99');
185
+ $this->assertEquals('foo.co:99', $uri->getAuthority());
186
+
187
+ // No scheme
188
+ $uri = new Uri('foo.co:99');
189
+ $this->assertEquals('foo.co:99', $uri->getAuthority());
190
+
191
+ // No host or port
192
+ $uri = new Uri('http:');
193
+ $this->assertEquals('', $uri->getAuthority());
194
+
195
+ // No host or port
196
+ $uri = new Uri('http://foo.co');
197
+ $this->assertEquals('foo.co', $uri->getAuthority());
198
+ }
199
+
200
+ public function pathTestProvider()
201
+ {
202
+ return [
203
+ // Percent encode spaces.
204
+ ['http://foo.com/baz bar', 'http://foo.com/baz%20bar'],
205
+ // Don't encoding something that's already encoded.
206
+ ['http://foo.com/baz%20bar', 'http://foo.com/baz%20bar'],
207
+ // Percent encode invalid percent encodings
208
+ ['http://foo.com/baz%2-bar', 'http://foo.com/baz%252-bar'],
209
+ // Don't encode path segments
210
+ ['http://foo.com/baz/bar/bam?a', 'http://foo.com/baz/bar/bam?a'],
211
+ ['http://foo.com/baz+bar', 'http://foo.com/baz+bar'],
212
+ ['http://foo.com/baz:bar', 'http://foo.com/baz:bar'],
213
+ ['http://foo.com/baz@bar', 'http://foo.com/baz@bar'],
214
+ ['http://foo.com/baz(bar);bam/', 'http://foo.com/baz(bar);bam/'],
215
+ ['http://foo.com/a-zA-Z0-9.-_~!$&\'()*+,;=:@', 'http://foo.com/a-zA-Z0-9.-_~!$&\'()*+,;=:@'],
216
+ ];
217
+ }
218
+
219
+ /**
220
+ * @dataProvider pathTestProvider
221
+ */
222
+ public function testUriEncodesPathProperly($input, $output)
223
+ {
224
+ $uri = new Uri($input);
225
+ $this->assertEquals((string) $uri, $output);
226
+ }
227
+
228
+ public function testDoesNotAddPortWhenNoPort()
229
+ {
230
+ $this->assertEquals('bar', new Uri('//bar'));
231
+ $this->assertEquals('bar', (new Uri('//bar'))->getHost());
232
+ }
233
+
234
+ public function testAllowsForRelativeUri()
235
+ {
236
+ $uri = (new Uri)->withPath('foo');
237
+ $this->assertEquals('foo', $uri->getPath());
238
+ $this->assertEquals('foo', (string) $uri);
239
+ }
240
+
241
+ public function testAddsSlashForRelativeUriStringWithHost()
242
+ {
243
+ $uri = (new Uri)->withPath('foo')->withHost('bar.com');
244
+ $this->assertEquals('foo', $uri->getPath());
245
+ $this->assertEquals('bar.com/foo', (string) $uri);
246
+ }
247
+
248
+ /**
249
+ * @dataProvider pathTestNoAuthority
250
+ */
251
+ public function testNoAuthority($input)
252
+ {
253
+ $uri = new Uri($input);
254
+
255
+ $this->assertEquals($input, (string) $uri);
256
+ }
257
+
258
+ public function pathTestNoAuthority()
259
+ {
260
+ return [
261
+ // path-rootless
262
+ ['urn:example:animal:ferret:nose'],
263
+ // path-absolute
264
+ ['urn:/example:animal:ferret:nose'],
265
+ ['urn:/'],
266
+ // path-empty
267
+ ['urn:'],
268
+ ['urn'],
269
+ ];
270
+ }
271
+
272
+ /**
273
+ * @expectedException \InvalidArgumentException
274
+ * @expectedExceptionMessage Unable to parse URI
275
+ */
276
+ public function testNoAuthorityWithInvalidPath()
277
+ {
278
+ $input = 'urn://example:animal:ferret:nose';
279
+ $uri = new Uri($input);
280
+ }
281
+ }
app/api/Ctct/vendor/guzzlehttp/psr7/tests/bootstrap.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Tests\Psr7;
3
+
4
+ require __DIR__ . '/../vendor/autoload.php';
5
+
6
+ class HasToString
7
+ {
8
+ public function __toString() {
9
+ return 'foo';
10
+ }
11
+ }
app/api/Ctct/vendor/psr/http-message/LICENSE ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Copyright (c) 2014 PHP Framework Interoperability Group
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.
app/api/Ctct/vendor/psr/http-message/README.md ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ PSR Http Message
2
+ ================
3
+
4
+ This repository holds all interfaces/classes/traits related to
5
+ [PSR-7](http://www.php-fig.org/psr/psr-7/).
6
+
7
+ Note that this is not a HTTP message implementation of its own. It is merely an
8
+ interface that describes a HTTP message. See the specification for more details.
9
+
10
+ Usage
11
+ -----
12
+
13
+ We'll certainly need some stuff in here.
app/api/Ctct/vendor/psr/http-message/composer.json ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "psr/http-message",
3
+ "description": "Common interface for HTTP messages",
4
+ "keywords": ["psr", "psr-7", "http", "http-message", "request", "response"],
5
+ "license": "MIT",
6
+ "authors": [
7
+ {
8
+ "name": "PHP-FIG",
9
+ "homepage": "http://www.php-fig.org/"
10
+ }
11
+ ],
12
+ "require": {
13
+ "php": ">=5.3.0"
14
+ },
15
+ "autoload": {
16
+ "psr-4": {
17
+ "Psr\\Http\\Message\\": "src/"
18
+ }
19
+ },
20
+ "extra": {
21
+ "branch-alias": {
22
+ "dev-master": "1.0.x-dev"
23
+ }
24
+ }
25
+ }
app/api/Ctct/vendor/psr/http-message/src/MessageInterface.php ADDED
@@ -0,0 +1,187 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Psr\Http\Message;
4
+
5
+ /**
6
+ * HTTP messages consist of requests from a client to a server and responses
7
+ * from a server to a client. This interface defines the methods common to
8
+ * each.
9
+ *
10
+ * Messages are considered immutable; all methods that might change state MUST
11
+ * be implemented such that they retain the internal state of the current
12
+ * message and return an instance that contains the changed state.
13
+ *
14
+ * @link http://www.ietf.org/rfc/rfc7230.txt
15
+ * @link http://www.ietf.org/rfc/rfc7231.txt
16
+ */
17
+ interface MessageInterface
18
+ {
19
+ /**
20
+ * Retrieves the HTTP protocol version as a string.
21
+ *
22
+ * The string MUST contain only the HTTP version number (e.g., "1.1", "1.0").
23
+ *
24
+ * @return string HTTP protocol version.
25
+ */
26
+ public function getProtocolVersion();
27
+
28
+ /**
29
+ * Return an instance with the specified HTTP protocol version.
30
+ *
31
+ * The version string MUST contain only the HTTP version number (e.g.,
32
+ * "1.1", "1.0").
33
+ *
34
+ * This method MUST be implemented in such a way as to retain the
35
+ * immutability of the message, and MUST return an instance that has the
36
+ * new protocol version.
37
+ *
38
+ * @param string $version HTTP protocol version
39
+ * @return self
40
+ */
41
+ public function withProtocolVersion($version);
42
+
43
+ /**
44
+ * Retrieves all message header values.
45
+ *
46
+ * The keys represent the header name as it will be sent over the wire, and
47
+ * each value is an array of strings associated with the header.
48
+ *
49
+ * // Represent the headers as a string
50
+ * foreach ($message->getHeaders() as $name => $values) {
51
+ * echo $name . ": " . implode(", ", $values);
52
+ * }
53
+ *
54
+ * // Emit headers iteratively:
55
+ * foreach ($message->getHeaders() as $name => $values) {
56
+ * foreach ($values as $value) {
57
+ * header(sprintf('%s: %s', $name, $value), false);
58
+ * }
59
+ * }
60
+ *
61
+ * While header names are not case-sensitive, getHeaders() will preserve the
62
+ * exact case in which headers were originally specified.
63
+ *
64
+ * @return array Returns an associative array of the message's headers. Each
65
+ * key MUST be a header name, and each value MUST be an array of strings
66
+ * for that header.
67
+ */
68
+ public function getHeaders();
69
+
70
+ /**
71
+ * Checks if a header exists by the given case-insensitive name.
72
+ *
73
+ * @param string $name Case-insensitive header field name.
74
+ * @return bool Returns true if any header names match the given header
75
+ * name using a case-insensitive string comparison. Returns false if
76
+ * no matching header name is found in the message.
77
+ */
78
+ public function hasHeader($name);
79
+
80
+ /**
81
+ * Retrieves a message header value by the given case-insensitive name.
82
+ *
83
+ * This method returns an array of all the header values of the given
84
+ * case-insensitive header name.
85
+ *
86
+ * If the header does not appear in the message, this method MUST return an
87
+ * empty array.
88
+ *
89
+ * @param string $name Case-insensitive header field name.
90
+ * @return string[] An array of string values as provided for the given
91
+ * header. If the header does not appear in the message, this method MUST
92
+ * return an empty array.
93
+ */
94
+ public function getHeader($name);
95
+
96
+ /**
97
+ * Retrieves a comma-separated string of the values for a single header.
98
+ *
99
+ * This method returns all of the header values of the given
100
+ * case-insensitive header name as a string concatenated together using
101
+ * a comma.
102
+ *
103
+ * NOTE: Not all header values may be appropriately represented using
104
+ * comma concatenation. For such headers, use getHeader() instead
105
+ * and supply your own delimiter when concatenating.
106
+ *
107
+ * If the header does not appear in the message, this method MUST return
108
+ * an empty string.
109
+ *
110
+ * @param string $name Case-insensitive header field name.
111
+ * @return string A string of values as provided for the given header
112
+ * concatenated together using a comma. If the header does not appear in
113
+ * the message, this method MUST return an empty string.
114
+ */
115
+ public function getHeaderLine($name);
116
+
117
+ /**
118
+ * Return an instance with the provided value replacing the specified header.
119
+ *
120
+ * While header names are case-insensitive, the casing of the header will
121
+ * be preserved by this function, and returned from getHeaders().
122
+ *
123
+ * This method MUST be implemented in such a way as to retain the
124
+ * immutability of the message, and MUST return an instance that has the
125
+ * new and/or updated header and value.
126
+ *
127
+ * @param string $name Case-insensitive header field name.
128
+ * @param string|string[] $value Header value(s).
129
+ * @return self
130
+ * @throws \InvalidArgumentException for invalid header names or values.
131
+ */
132
+ public function withHeader($name, $value);
133
+
134
+ /**
135
+ * Return an instance with the specified header appended with the given value.
136
+ *
137
+ * Existing values for the specified header will be maintained. The new
138
+ * value(s) will be appended to the existing list. If the header did not
139
+ * exist previously, it will be added.
140
+ *
141
+ * This method MUST be implemented in such a way as to retain the
142
+ * immutability of the message, and MUST return an instance that has the
143
+ * new header and/or value.
144
+ *
145
+ * @param string $name Case-insensitive header field name to add.
146
+ * @param string|string[] $value Header value(s).
147
+ * @return self
148
+ * @throws \InvalidArgumentException for invalid header names or values.
149
+ */
150
+ public function withAddedHeader($name, $value);
151
+
152
+ /**
153
+ * Return an instance without the specified header.
154
+ *
155
+ * Header resolution MUST be done without case-sensitivity.
156
+ *
157
+ * This method MUST be implemented in such a way as to retain the
158
+ * immutability of the message, and MUST return an instance that removes
159
+ * the named header.
160
+ *
161
+ * @param string $name Case-insensitive header field name to remove.
162
+ * @return self
163
+ */
164
+ public function withoutHeader($name);
165
+
166
+ /**
167
+ * Gets the body of the message.
168
+ *
169
+ * @return StreamInterface Returns the body as a stream.
170
+ */
171
+ public function getBody();
172
+
173
+ /**
174
+ * Return an instance with the specified message body.
175
+ *
176
+ * The body MUST be a StreamInterface object.
177
+ *
178
+ * This method MUST be implemented in such a way as to retain the
179
+ * immutability of the message, and MUST return a new instance that has the
180
+ * new body stream.
181
+ *
182
+ * @param StreamInterface $body Body.
183
+ * @return self
184
+ * @throws \InvalidArgumentException When the body is not valid.
185
+ */
186
+ public function withBody(StreamInterface $body);
187
+ }
app/api/Ctct/vendor/psr/http-message/src/RequestInterface.php ADDED
@@ -0,0 +1,129 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Psr\Http\Message;
4
+
5
+ /**
6
+ * Representation of an outgoing, client-side request.
7
+ *
8
+ * Per the HTTP specification, this interface includes properties for
9
+ * each of the following:
10
+ *
11
+ * - Protocol version
12
+ * - HTTP method
13
+ * - URI
14
+ * - Headers
15
+ * - Message body
16
+ *
17
+ * During construction, implementations MUST attempt to set the Host header from
18
+ * a provided URI if no Host header is provided.
19
+ *
20
+ * Requests are considered immutable; all methods that might change state MUST
21
+ * be implemented such that they retain the internal state of the current
22
+ * message and return an instance that contains the changed state.
23
+ */
24
+ interface RequestInterface extends MessageInterface
25
+ {
26
+ /**
27
+ * Retrieves the message's request target.
28
+ *
29
+ * Retrieves the message's request-target either as it will appear (for
30
+ * clients), as it appeared at request (for servers), or as it was
31
+ * specified for the instance (see withRequestTarget()).
32
+ *
33
+ * In most cases, this will be the origin-form of the composed URI,
34
+ * unless a value was provided to the concrete implementation (see
35
+ * withRequestTarget() below).
36
+ *
37
+ * If no URI is available, and no request-target has been specifically
38
+ * provided, this method MUST return the string "/".
39
+ *
40
+ * @return string
41
+ */
42
+ public function getRequestTarget();
43
+
44
+ /**
45
+ * Return an instance with the specific request-target.
46
+ *
47
+ * If the request needs a non-origin-form request-target — e.g., for
48
+ * specifying an absolute-form, authority-form, or asterisk-form —
49
+ * this method may be used to create an instance with the specified
50
+ * request-target, verbatim.
51
+ *
52
+ * This method MUST be implemented in such a way as to retain the
53
+ * immutability of the message, and MUST return an instance that has the
54
+ * changed request target.
55
+ *
56
+ * @link http://tools.ietf.org/html/rfc7230#section-2.7 (for the various
57
+ * request-target forms allowed in request messages)
58
+ * @param mixed $requestTarget
59
+ * @return self
60
+ */
61
+ public function withRequestTarget($requestTarget);
62
+
63
+ /**
64
+ * Retrieves the HTTP method of the request.
65
+ *
66
+ * @return string Returns the request method.
67
+ */
68
+ public function getMethod();
69
+
70
+ /**
71
+ * Return an instance with the provided HTTP method.
72
+ *
73
+ * While HTTP method names are typically all uppercase characters, HTTP
74
+ * method names are case-sensitive and thus implementations SHOULD NOT
75
+ * modify the given string.
76
+ *
77
+ * This method MUST be implemented in such a way as to retain the
78
+ * immutability of the message, and MUST return an instance that has the
79
+ * changed request method.
80
+ *
81
+ * @param string $method Case-sensitive method.
82
+ * @return self
83
+ * @throws \InvalidArgumentException for invalid HTTP methods.
84
+ */
85
+ public function withMethod($method);
86
+
87
+ /**
88
+ * Retrieves the URI instance.
89
+ *
90
+ * This method MUST return a UriInterface instance.
91
+ *
92
+ * @link http://tools.ietf.org/html/rfc3986#section-4.3
93
+ * @return UriInterface Returns a UriInterface instance
94
+ * representing the URI of the request.
95
+ */
96
+ public function getUri();
97
+
98
+ /**
99
+ * Returns an instance with the provided URI.
100
+ *
101
+ * This method MUST update the Host header of the returned request by
102
+ * default if the URI contains a host component. If the URI does not
103
+ * contain a host component, any pre-existing Host header MUST be carried
104
+ * over to the returned request.
105
+ *
106
+ * You can opt-in to preserving the original state of the Host header by
107
+ * setting `$preserveHost` to `true`. When `$preserveHost` is set to
108
+ * `true`, this method interacts with the Host header in the following ways:
109
+ *
110
+ * - If the the Host header is missing or empty, and the new URI contains
111
+ * a host component, this method MUST update the Host header in the returned
112
+ * request.
113
+ * - If the Host header is missing or empty, and the new URI does not contain a
114
+ * host component, this method MUST NOT update the Host header in the returned
115
+ * request.
116
+ * - If a Host header is present and non-empty, this method MUST NOT update
117
+ * the Host header in the returned request.
118
+ *
119
+ * This method MUST be implemented in such a way as to retain the
120
+ * immutability of the message, and MUST return an instance that has the
121
+ * new UriInterface instance.
122
+ *
123
+ * @link http://tools.ietf.org/html/rfc3986#section-4.3
124
+ * @param UriInterface $uri New request URI to use.
125
+ * @param bool $preserveHost Preserve the original state of the Host header.
126
+ * @return self
127
+ */
128
+ public function withUri(UriInterface $uri, $preserveHost = false);
129
+ }
app/api/Ctct/vendor/psr/http-message/src/ResponseInterface.php ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Psr\Http\Message;
4
+
5
+ /**
6
+ * Representation of an outgoing, server-side response.
7
+ *
8
+ * Per the HTTP specification, this interface includes properties for
9
+ * each of the following:
10
+ *
11
+ * - Protocol version
12
+ * - Status code and reason phrase
13
+ * - Headers
14
+ * - Message body
15
+ *
16
+ * Responses are considered immutable; all methods that might change state MUST
17
+ * be implemented such that they retain the internal state of the current
18
+ * message and return an instance that contains the changed state.
19
+ */
20
+ interface ResponseInterface extends MessageInterface
21
+ {
22
+ /**
23
+ * Gets the response status code.
24
+ *
25
+ * The status code is a 3-digit integer result code of the server's attempt
26
+ * to understand and satisfy the request.
27
+ *
28
+ * @return int Status code.
29
+ */
30
+ public function getStatusCode();
31
+
32
+ /**
33
+ * Return an instance with the specified status code and, optionally, reason phrase.
34
+ *
35
+ * If no reason phrase is specified, implementations MAY choose to default
36
+ * to the RFC 7231 or IANA recommended reason phrase for the response's
37
+ * status code.
38
+ *
39
+ * This method MUST be implemented in such a way as to retain the
40
+ * immutability of the message, and MUST return an instance that has the
41
+ * updated status and reason phrase.
42
+ *
43
+ * @link http://tools.ietf.org/html/rfc7231#section-6
44
+ * @link http://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml
45
+ * @param int $code The 3-digit integer result code to set.
46
+ * @param string $reasonPhrase The reason phrase to use with the
47
+ * provided status code; if none is provided, implementations MAY
48
+ * use the defaults as suggested in the HTTP specification.
49
+ * @return self
50
+ * @throws \InvalidArgumentException For invalid status code arguments.
51
+ */
52
+ public function withStatus($code, $reasonPhrase = '');
53
+
54
+ /**
55
+ * Gets the response reason phrase associated with the status code.
56
+ *
57
+ * Because a reason phrase is not a required element in a response
58
+ * status line, the reason phrase value MAY be null. Implementations MAY
59
+ * choose to return the default RFC 7231 recommended reason phrase (or those
60
+ * listed in the IANA HTTP Status Code Registry) for the response's
61
+ * status code.
62
+ *
63
+ * @link http://tools.ietf.org/html/rfc7231#section-6
64
+ * @link http://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml
65
+ * @return string Reason phrase; must return an empty string if none present.
66
+ */
67
+ public function getReasonPhrase();
68
+ }
app/api/Ctct/vendor/psr/http-message/src/ServerRequestInterface.php ADDED
@@ -0,0 +1,261 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Psr\Http\Message;
4
+
5
+ /**
6
+ * Representation of an incoming, server-side HTTP request.
7
+ *
8
+ * Per the HTTP specification, this interface includes properties for
9
+ * each of the following:
10
+ *
11
+ * - Protocol version
12
+ * - HTTP method
13
+ * - URI
14
+ * - Headers
15
+ * - Message body
16
+ *
17
+ * Additionally, it encapsulates all data as it has arrived to the
18
+ * application from the CGI and/or PHP environment, including:
19
+ *
20
+ * - The values represented in $_SERVER.
21
+ * - Any cookies provided (generally via $_COOKIE)
22
+ * - Query string arguments (generally via $_GET, or as parsed via parse_str())
23
+ * - Upload files, if any (as represented by $_FILES)
24
+ * - Deserialized body parameters (generally from $_POST)
25
+ *
26
+ * $_SERVER values MUST be treated as immutable, as they represent application
27
+ * state at the time of request; as such, no methods are provided to allow
28
+ * modification of those values. The other values provide such methods, as they
29
+ * can be restored from $_SERVER or the request body, and may need treatment
30
+ * during the application (e.g., body parameters may be deserialized based on
31
+ * content type).
32
+ *
33
+ * Additionally, this interface recognizes the utility of introspecting a
34
+ * request to derive and match additional parameters (e.g., via URI path
35
+ * matching, decrypting cookie values, deserializing non-form-encoded body
36
+ * content, matching authorization headers to users, etc). These parameters
37
+ * are stored in an "attributes" property.
38
+ *
39
+ * Requests are considered immutable; all methods that might change state MUST
40
+ * be implemented such that they retain the internal state of the current
41
+ * message and return an instance that contains the changed state.
42
+ */
43
+ interface ServerRequestInterface extends RequestInterface
44
+ {
45
+ /**
46
+ * Retrieve server parameters.
47
+ *
48
+ * Retrieves data related to the incoming request environment,
49
+ * typically derived from PHP's $_SERVER superglobal. The data IS NOT
50
+ * REQUIRED to originate from $_SERVER.
51
+ *
52
+ * @return array
53
+ */
54
+ public function getServerParams();
55
+
56
+ /**
57
+ * Retrieve cookies.
58
+ *
59
+ * Retrieves cookies sent by the client to the server.
60
+ *
61
+ * The data MUST be compatible with the structure of the $_COOKIE
62
+ * superglobal.
63
+ *
64
+ * @return array
65
+ */
66
+ public function getCookieParams();
67
+
68
+ /**
69
+ * Return an instance with the specified cookies.
70
+ *
71
+ * The data IS NOT REQUIRED to come from the $_COOKIE superglobal, but MUST
72
+ * be compatible with the structure of $_COOKIE. Typically, this data will
73
+ * be injected at instantiation.
74
+ *
75
+ * This method MUST NOT update the related Cookie header of the request
76
+ * instance, nor related values in the server params.
77
+ *
78
+ * This method MUST be implemented in such a way as to retain the
79
+ * immutability of the message, and MUST return an instance that has the
80
+ * updated cookie values.
81
+ *
82
+ * @param array $cookies Array of key/value pairs representing cookies.
83
+ * @return self
84
+ */
85
+ public function withCookieParams(array $cookies);
86
+
87
+ /**
88
+ * Retrieve query string arguments.
89
+ *
90
+ * Retrieves the deserialized query string arguments, if any.
91
+ *
92
+ * Note: the query params might not be in sync with the URI or server
93
+ * params. If you need to ensure you are only getting the original
94
+ * values, you may need to parse the query string from `getUri()->getQuery()`
95
+ * or from the `QUERY_STRING` server param.
96
+ *
97
+ * @return array
98
+ */
99
+ public function getQueryParams();
100
+
101
+ /**
102
+ * Return an instance with the specified query string arguments.
103
+ *
104
+ * These values SHOULD remain immutable over the course of the incoming
105
+ * request. They MAY be injected during instantiation, such as from PHP's
106
+ * $_GET superglobal, or MAY be derived from some other value such as the
107
+ * URI. In cases where the arguments are parsed from the URI, the data
108
+ * MUST be compatible with what PHP's parse_str() would return for
109
+ * purposes of how duplicate query parameters are handled, and how nested
110
+ * sets are handled.
111
+ *
112
+ * Setting query string arguments MUST NOT change the URI stored by the
113
+ * request, nor the values in the server params.
114
+ *
115
+ * This method MUST be implemented in such a way as to retain the
116
+ * immutability of the message, and MUST return an instance that has the
117
+ * updated query string arguments.
118
+ *
119
+ * @param array $query Array of query string arguments, typically from
120
+ * $_GET.
121
+ * @return self
122
+ */
123
+ public function withQueryParams(array $query);
124
+
125
+ /**
126
+ * Retrieve normalized file upload data.
127
+ *
128
+ * This method returns upload metadata in a normalized tree, with each leaf
129
+ * an instance of Psr\Http\Message\UploadedFileInterface.
130
+ *
131
+ * These values MAY be prepared from $_FILES or the message body during
132
+ * instantiation, or MAY be injected via withUploadedFiles().
133
+ *
134
+ * @return array An array tree of UploadedFileInterface instances; an empty
135
+ * array MUST be returned if no data is present.
136
+ */
137
+ public function getUploadedFiles();
138
+
139
+ /**
140
+ * Create a new instance with the specified uploaded files.
141
+ *
142
+ * This method MUST be implemented in such a way as to retain the
143
+ * immutability of the message, and MUST return an instance that has the
144
+ * updated body parameters.
145
+ *
146
+ * @param array An array tree of UploadedFileInterface instances.
147
+ * @return self
148
+ * @throws \InvalidArgumentException if an invalid structure is provided.
149
+ */
150
+ public function withUploadedFiles(array $uploadedFiles);
151
+
152
+ /**
153
+ * Retrieve any parameters provided in the request body.
154
+ *
155
+ * If the request Content-Type is either application/x-www-form-urlencoded
156
+ * or multipart/form-data, and the request method is POST, this method MUST
157
+ * return the contents of $_POST.
158
+ *
159
+ * Otherwise, this method may return any results of deserializing
160
+ * the request body content; as parsing returns structured content, the
161
+ * potential types MUST be arrays or objects only. A null value indicates
162
+ * the absence of body content.
163
+ *
164
+ * @return null|array|object The deserialized body parameters, if any.
165
+ * These will typically be an array or object.
166
+ */
167
+ public function getParsedBody();
168
+
169
+ /**
170
+ * Return an instance with the specified body parameters.
171
+ *
172
+ * These MAY be injected during instantiation.
173
+ *
174
+ * If the request Content-Type is either application/x-www-form-urlencoded
175
+ * or multipart/form-data, and the request method is POST, use this method
176
+ * ONLY to inject the contents of $_POST.
177
+ *
178
+ * The data IS NOT REQUIRED to come from $_POST, but MUST be the results of
179
+ * deserializing the request body content. Deserialization/parsing returns
180
+ * structured data, and, as such, this method ONLY accepts arrays or objects,
181
+ * or a null value if nothing was available to parse.
182
+ *
183
+ * As an example, if content negotiation determines that the request data
184
+ * is a JSON payload, this method could be used to create a request
185
+ * instance with the deserialized parameters.
186
+ *
187
+ * This method MUST be implemented in such a way as to retain the
188
+ * immutability of the message, and MUST return an instance that has the
189
+ * updated body parameters.
190
+ *
191
+ * @param null|array|object $data The deserialized body data. This will
192
+ * typically be in an array or object.
193
+ * @return self
194
+ * @throws \InvalidArgumentException if an unsupported argument type is
195
+ * provided.
196
+ */
197
+ public function withParsedBody($data);
198
+
199
+ /**
200
+ * Retrieve attributes derived from the request.
201
+ *
202
+ * The request "attributes" may be used to allow injection of any
203
+ * parameters derived from the request: e.g., the results of path
204
+ * match operations; the results of decrypting cookies; the results of
205
+ * deserializing non-form-encoded message bodies; etc. Attributes
206
+ * will be application and request specific, and CAN be mutable.
207
+ *
208
+ * @return array Attributes derived from the request.
209
+ */
210
+ public function getAttributes();
211
+
212
+ /**
213
+ * Retrieve a single derived request attribute.
214
+ *
215
+ * Retrieves a single derived request attribute as described in
216
+ * getAttributes(). If the attribute has not been previously set, returns
217
+ * the default value as provided.
218
+ *
219
+ * This method obviates the need for a hasAttribute() method, as it allows
220
+ * specifying a default value to return if the attribute is not found.
221
+ *
222
+ * @see getAttributes()
223
+ * @param string $name The attribute name.
224
+ * @param mixed $default Default value to return if the attribute does not exist.
225
+ * @return mixed
226
+ */
227
+ public function getAttribute($name, $default = null);
228
+
229
+ /**
230
+ * Return an instance with the specified derived request attribute.
231
+ *
232
+ * This method allows setting a single derived request attribute as
233
+ * described in getAttributes().
234
+ *
235
+ * This method MUST be implemented in such a way as to retain the
236
+ * immutability of the message, and MUST return an instance that has the
237
+ * updated attribute.
238
+ *
239
+ * @see getAttributes()
240
+ * @param string $name The attribute name.
241
+ * @param mixed $value The value of the attribute.
242
+ * @return self
243
+ */
244
+ public function withAttribute($name, $value);
245
+
246
+ /**
247
+ * Return an instance that removes the specified derived request attribute.
248
+ *
249
+ * This method allows removing a single derived request attribute as
250
+ * described in getAttributes().
251
+ *
252
+ * This method MUST be implemented in such a way as to retain the
253
+ * immutability of the message, and MUST return an instance that removes
254
+ * the attribute.
255
+ *
256
+ * @see getAttributes()
257
+ * @param string $name The attribute name.
258
+ * @return self
259
+ */
260
+ public function withoutAttribute($name);
261
+ }
app/api/Ctct/vendor/psr/http-message/src/StreamInterface.php ADDED
@@ -0,0 +1,158 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Psr\Http\Message;
4
+
5
+ /**
6
+ * Describes a data stream.
7
+ *
8
+ * Typically, an instance will wrap a PHP stream; this interface provides
9
+ * a wrapper around the most common operations, including serialization of
10
+ * the entire stream to a string.
11
+ */
12
+ interface StreamInterface
13
+ {
14
+ /**
15
+ * Reads all data from the stream into a string, from the beginning to end.
16
+ *
17
+ * This method MUST attempt to seek to the beginning of the stream before
18
+ * reading data and read the stream until the end is reached.
19
+ *
20
+ * Warning: This could attempt to load a large amount of data into memory.
21
+ *
22
+ * This method MUST NOT raise an exception in order to conform with PHP's
23
+ * string casting operations.
24
+ *
25
+ * @see http://php.net/manual/en/language.oop5.magic.php#object.tostring
26
+ * @return string
27
+ */
28
+ public function __toString();
29
+
30
+ /**
31
+ * Closes the stream and any underlying resources.
32
+ *
33
+ * @return void
34
+ */
35
+ public function close();
36
+
37
+ /**
38
+ * Separates any underlying resources from the stream.
39
+ *
40
+ * After the stream has been detached, the stream is in an unusable state.
41
+ *
42
+ * @return resource|null Underlying PHP stream, if any
43
+ */
44
+ public function detach();
45
+
46
+ /**
47
+ * Get the size of the stream if known.
48
+ *
49
+ * @return int|null Returns the size in bytes if known, or null if unknown.
50
+ */
51
+ public function getSize();
52
+
53
+ /**
54
+ * Returns the current position of the file read/write pointer
55
+ *
56
+ * @return int Position of the file pointer
57
+ * @throws \RuntimeException on error.
58
+ */
59
+ public function tell();
60
+
61
+ /**
62
+ * Returns true if the stream is at the end of the stream.
63
+ *
64
+ * @return bool
65
+ */
66
+ public function eof();
67
+
68
+ /**
69
+ * Returns whether or not the stream is seekable.
70
+ *
71
+ * @return bool
72
+ */
73
+ public function isSeekable();
74
+
75
+ /**
76
+ * Seek to a position in the stream.
77
+ *
78
+ * @link http://www.php.net/manual/en/function.fseek.php
79
+ * @param int $offset Stream offset
80
+ * @param int $whence Specifies how the cursor position will be calculated
81
+ * based on the seek offset. Valid values are identical to the built-in
82
+ * PHP $whence values for `fseek()`. SEEK_SET: Set position equal to
83
+ * offset bytes SEEK_CUR: Set position to current location plus offset
84
+ * SEEK_END: Set position to end-of-stream plus offset.
85
+ * @throws \RuntimeException on failure.
86
+ */
87
+ public function seek($offset, $whence = SEEK_SET);
88
+
89
+ /**
90
+ * Seek to the beginning of the stream.
91
+ *
92
+ * If the stream is not seekable, this method will raise an exception;
93
+ * otherwise, it will perform a seek(0).
94
+ *
95
+ * @see seek()
96
+ * @link http://www.php.net/manual/en/function.fseek.php
97
+ * @throws \RuntimeException on failure.
98
+ */
99
+ public function rewind();
100
+
101
+ /**
102
+ * Returns whether or not the stream is writable.
103
+ *
104
+ * @return bool
105
+ */
106
+ public function isWritable();
107
+
108
+ /**
109
+ * Write data to the stream.
110
+ *
111
+ * @param string $string The string that is to be written.
112
+ * @return int Returns the number of bytes written to the stream.
113
+ * @throws \RuntimeException on failure.
114
+ */
115
+ public function write($string);
116
+
117
+ /**
118
+ * Returns whether or not the stream is readable.
119
+ *
120
+ * @return bool
121
+ */
122
+ public function isReadable();
123
+
124
+ /**
125
+ * Read data from the stream.
126
+ *
127
+ * @param int $length Read up to $length bytes from the object and return
128
+ * them. Fewer than $length bytes may be returned if underlying stream
129
+ * call returns fewer bytes.
130
+ * @return string Returns the data read from the stream, or an empty string
131
+ * if no bytes are available.
132
+ * @throws \RuntimeException if an error occurs.
133
+ */
134
+ public function read($length);
135
+
136
+ /**
137
+ * Returns the remaining contents in a string
138
+ *
139
+ * @return string
140
+ * @throws \RuntimeException if unable to read or an error occurs while
141
+ * reading.
142
+ */
143
+ public function getContents();
144
+
145
+ /**
146
+ * Get stream metadata as an associative array or retrieve a specific key.
147
+ *
148
+ * The keys returned are identical to the keys returned from PHP's
149
+ * stream_get_meta_data() function.
150
+ *
151
+ * @link http://php.net/manual/en/function.stream-get-meta-data.php
152
+ * @param string $key Specific metadata to retrieve.
153
+ * @return array|mixed|null Returns an associative array if no key is
154
+ * provided. Returns a specific key value if a key is provided and the
155
+ * value is found, or null if the key is not found.
156
+ */
157
+ public function getMetadata($key = null);
158
+ }
app/api/Ctct/vendor/psr/http-message/src/UploadedFileInterface.php ADDED
@@ -0,0 +1,123 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Psr\Http\Message;
4
+
5
+ /**
6
+ * Value object representing a file uploaded through an HTTP request.
7
+ *
8
+ * Instances of this interface are considered immutable; all methods that
9
+ * might change state MUST be implemented such that they retain the internal
10
+ * state of the current instance and return an instance that contains the
11
+ * changed state.
12
+ */
13
+ interface UploadedFileInterface
14
+ {
15
+ /**
16
+ * Retrieve a stream representing the uploaded file.
17
+ *
18
+ * This method MUST return a StreamInterface instance, representing the
19
+ * uploaded file. The purpose of this method is to allow utilizing native PHP
20
+ * stream functionality to manipulate the file upload, such as
21
+ * stream_copy_to_stream() (though the result will need to be decorated in a
22
+ * native PHP stream wrapper to work with such functions).
23
+ *
24
+ * If the moveTo() method has been called previously, this method MUST raise
25
+ * an exception.
26
+ *
27
+ * @return StreamInterface Stream representation of the uploaded file.
28
+ * @throws \RuntimeException in cases when no stream is available or can be
29
+ * created.
30
+ */
31
+ public function getStream();
32
+
33
+ /**
34
+ * Move the uploaded file to a new location.
35
+ *
36
+ * Use this method as an alternative to move_uploaded_file(). This method is
37
+ * guaranteed to work in both SAPI and non-SAPI environments.
38
+ * Implementations must determine which environment they are in, and use the
39
+ * appropriate method (move_uploaded_file(), rename(), or a stream
40
+ * operation) to perform the operation.
41
+ *
42
+ * $targetPath may be an absolute path, or a relative path. If it is a
43
+ * relative path, resolution should be the same as used by PHP's rename()
44
+ * function.
45
+ *
46
+ * The original file or stream MUST be removed on completion.
47
+ *
48
+ * If this method is called more than once, any subsequent calls MUST raise
49
+ * an exception.
50
+ *
51
+ * When used in an SAPI environment where $_FILES is populated, when writing
52
+ * files via moveTo(), is_uploaded_file() and move_uploaded_file() SHOULD be
53
+ * used to ensure permissions and upload status are verified correctly.
54
+ *
55
+ * If you wish to move to a stream, use getStream(), as SAPI operations
56
+ * cannot guarantee writing to stream destinations.
57
+ *
58
+ * @see http://php.net/is_uploaded_file
59
+ * @see http://php.net/move_uploaded_file
60
+ * @param string $targetPath Path to which to move the uploaded file.
61
+ * @throws \InvalidArgumentException if the $path specified is invalid.
62
+ * @throws \RuntimeException on any error during the move operation, or on
63
+ * the second or subsequent call to the method.
64
+ */
65
+ public function moveTo($targetPath);
66
+
67
+ /**
68
+ * Retrieve the file size.
69
+ *
70
+ * Implementations SHOULD return the value stored in the "size" key of
71
+ * the file in the $_FILES array if available, as PHP calculates this based
72
+ * on the actual size transmitted.
73
+ *
74
+ * @return int|null The file size in bytes or null if unknown.
75
+ */
76
+ public function getSize();
77
+
78
+ /**
79
+ * Retrieve the error associated with the uploaded file.
80
+ *
81
+ * The return value MUST be one of PHP's UPLOAD_ERR_XXX constants.
82
+ *
83
+ * If the file was uploaded successfully, this method MUST return
84
+ * UPLOAD_ERR_OK.
85
+ *
86
+ * Implementations SHOULD return the value stored in the "error" key of
87
+ * the file in the $_FILES array.
88
+ *
89
+ * @see http://php.net/manual/en/features.file-upload.errors.php
90
+ * @return int One of PHP's UPLOAD_ERR_XXX constants.
91
+ */
92
+ public function getError();
93
+
94
+ /**
95
+ * Retrieve the filename sent by the client.
96
+ *
97
+ * Do not trust the value returned by this method. A client could send
98
+ * a malicious filename with the intention to corrupt or hack your
99
+ * application.
100
+ *
101
+ * Implementations SHOULD return the value stored in the "name" key of
102
+ * the file in the $_FILES array.
103
+ *
104
+ * @return string|null The filename sent by the client or null if none
105
+ * was provided.
106
+ */
107
+ public function getClientFilename();
108
+
109
+ /**
110
+ * Retrieve the media type sent by the client.
111
+ *
112
+ * Do not trust the value returned by this method. A client could send
113
+ * a malicious media type with the intention to corrupt or hack your
114
+ * application.
115
+ *
116
+ * Implementations SHOULD return the value stored in the "type" key of
117
+ * the file in the $_FILES array.
118
+ *
119
+ * @return string|null The media type sent by the client or null if none
120
+ * was provided.
121
+ */
122
+ public function getClientMediaType();
123
+ }
app/api/Ctct/vendor/psr/http-message/src/UriInterface.php ADDED
@@ -0,0 +1,323 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Psr\Http\Message;
3
+
4
+ /**
5
+ * Value object representing a URI.
6
+ *
7
+ * This interface is meant to represent URIs according to RFC 3986 and to
8
+ * provide methods for most common operations. Additional functionality for
9
+ * working with URIs can be provided on top of the interface or externally.
10
+ * Its primary use is for HTTP requests, but may also be used in other
11
+ * contexts.
12
+ *
13
+ * Instances of this interface are considered immutable; all methods that
14
+ * might change state MUST be implemented such that they retain the internal
15
+ * state of the current instance and return an instance that contains the
16
+ * changed state.
17
+ *
18
+ * Typically the Host header will be also be present in the request message.
19
+ * For server-side requests, the scheme will typically be discoverable in the
20
+ * server parameters.
21
+ *
22
+ * @link http://tools.ietf.org/html/rfc3986 (the URI specification)
23
+ */
24
+ interface UriInterface
25
+ {
26
+ /**
27
+ * Retrieve the scheme component of the URI.
28
+ *
29
+ * If no scheme is present, this method MUST return an empty string.
30
+ *
31
+ * The value returned MUST be normalized to lowercase, per RFC 3986
32
+ * Section 3.1.
33
+ *
34
+ * The trailing ":" character is not part of the scheme and MUST NOT be
35
+ * added.
36
+ *
37
+ * @see https://tools.ietf.org/html/rfc3986#section-3.1
38
+ * @return string The URI scheme.
39
+ */
40
+ public function getScheme();
41
+
42
+ /**
43
+ * Retrieve the authority component of the URI.
44
+ *
45
+ * If no authority information is present, this method MUST return an empty
46
+ * string.
47
+ *
48
+ * The authority syntax of the URI is:
49
+ *
50
+ * <pre>
51
+ * [user-info@]host[:port]
52
+ * </pre>
53
+ *
54
+ * If the port component is not set or is the standard port for the current
55
+ * scheme, it SHOULD NOT be included.
56
+ *
57
+ * @see https://tools.ietf.org/html/rfc3986#section-3.2
58
+ * @return string The URI authority, in "[user-info@]host[:port]" format.
59
+ */
60
+ public function getAuthority();
61
+
62
+ /**
63
+ * Retrieve the user information component of the URI.
64
+ *
65
+ * If no user information is present, this method MUST return an empty
66
+ * string.
67
+ *
68
+ * If a user is present in the URI, this will return that value;
69
+ * additionally, if the password is also present, it will be appended to the
70
+ * user value, with a colon (":") separating the values.
71
+ *
72
+ * The trailing "@" character is not part of the user information and MUST
73
+ * NOT be added.
74
+ *
75
+ * @return string The URI user information, in "username[:password]" format.
76
+ */
77
+ public function getUserInfo();
78
+
79
+ /**
80
+ * Retrieve the host component of the URI.
81
+ *
82
+ * If no host is present, this method MUST return an empty string.
83
+ *
84
+ * The value returned MUST be normalized to lowercase, per RFC 3986
85
+ * Section 3.2.2.
86
+ *
87
+ * @see http://tools.ietf.org/html/rfc3986#section-3.2.2
88
+ * @return string The URI host.
89
+ */
90
+ public function getHost();
91
+
92
+ /**
93
+ * Retrieve the port component of the URI.
94
+ *
95
+ * If a port is present, and it is non-standard for the current scheme,
96
+ * this method MUST return it as an integer. If the port is the standard port
97
+ * used with the current scheme, this method SHOULD return null.
98
+ *
99
+ * If no port is present, and no scheme is present, this method MUST return
100
+ * a null value.
101
+ *
102
+ * If no port is present, but a scheme is present, this method MAY return
103
+ * the standard port for that scheme, but SHOULD return null.
104
+ *
105
+ * @return null|int The URI port.
106
+ */
107
+ public function getPort();
108
+
109
+ /**
110
+ * Retrieve the path component of the URI.
111
+ *
112
+ * The path can either be empty or absolute (starting with a slash) or
113
+ * rootless (not starting with a slash). Implementations MUST support all
114
+ * three syntaxes.
115
+ *
116
+ * Normally, the empty path "" and absolute path "/" are considered equal as
117
+ * defined in RFC 7230 Section 2.7.3. But this method MUST NOT automatically
118
+ * do this normalization because in contexts with a trimmed base path, e.g.
119
+ * the front controller, this difference becomes significant. It's the task
120
+ * of the user to handle both "" and "/".
121
+ *
122
+ * The value returned MUST be percent-encoded, but MUST NOT double-encode
123
+ * any characters. To determine what characters to encode, please refer to
124
+ * RFC 3986, Sections 2 and 3.3.
125
+ *
126
+ * As an example, if the value should include a slash ("/") not intended as
127
+ * delimiter between path segments, that value MUST be passed in encoded
128
+ * form (e.g., "%2F") to the instance.
129
+ *
130
+ * @see https://tools.ietf.org/html/rfc3986#section-2
131
+ * @see https://tools.ietf.org/html/rfc3986#section-3.3
132
+ * @return string The URI path.
133
+ */
134
+ public function getPath();
135
+
136
+ /**
137
+ * Retrieve the query string of the URI.
138
+ *
139
+ * If no query string is present, this method MUST return an empty string.
140
+ *
141
+ * The leading "?" character is not part of the query and MUST NOT be
142
+ * added.
143
+ *
144
+ * The value returned MUST be percent-encoded, but MUST NOT double-encode
145
+ * any characters. To determine what characters to encode, please refer to
146
+ * RFC 3986, Sections 2 and 3.4.
147
+ *
148
+ * As an example, if a value in a key/value pair of the query string should
149
+ * include an ampersand ("&") not intended as a delimiter between values,
150
+ * that value MUST be passed in encoded form (e.g., "%26") to the instance.
151
+ *
152
+ * @see https://tools.ietf.org/html/rfc3986#section-2
153
+ * @see https://tools.ietf.org/html/rfc3986#section-3.4
154
+ * @return string The URI query string.
155
+ */
156
+ public function getQuery();
157
+
158
+ /**
159
+ * Retrieve the fragment component of the URI.
160
+ *
161
+ * If no fragment is present, this method MUST return an empty string.
162
+ *
163
+ * The leading "#" character is not part of the fragment and MUST NOT be
164
+ * added.
165
+ *
166
+ * The value returned MUST be percent-encoded, but MUST NOT double-encode
167
+ * any characters. To determine what characters to encode, please refer to
168
+ * RFC 3986, Sections 2 and 3.5.
169
+ *
170
+ * @see https://tools.ietf.org/html/rfc3986#section-2
171
+ * @see https://tools.ietf.org/html/rfc3986#section-3.5
172
+ * @return string The URI fragment.
173
+ */
174
+ public function getFragment();
175
+
176
+ /**
177
+ * Return an instance with the specified scheme.
178
+ *
179
+ * This method MUST retain the state of the current instance, and return
180
+ * an instance that contains the specified scheme.
181
+ *
182
+ * Implementations MUST support the schemes "http" and "https" case
183
+ * insensitively, and MAY accommodate other schemes if required.
184
+ *
185
+ * An empty scheme is equivalent to removing the scheme.
186
+ *
187
+ * @param string $scheme The scheme to use with the new instance.
188
+ * @return self A new instance with the specified scheme.
189
+ * @throws \InvalidArgumentException for invalid or unsupported schemes.
190
+ */
191
+ public function withScheme($scheme);
192
+
193
+ /**
194
+ * Return an instance with the specified user information.
195
+ *
196
+ * This method MUST retain the state of the current instance, and return
197
+ * an instance that contains the specified user information.
198
+ *
199
+ * Password is optional, but the user information MUST include the
200
+ * user; an empty string for the user is equivalent to removing user
201
+ * information.
202
+ *
203
+ * @param string $user The user name to use for authority.
204
+ * @param null|string $password The password associated with $user.
205
+ * @return self A new instance with the specified user information.
206
+ */
207
+ public function withUserInfo($user, $password = null);
208
+
209
+ /**
210
+ * Return an instance with the specified host.
211
+ *
212
+ * This method MUST retain the state of the current instance, and return
213
+ * an instance that contains the specified host.
214
+ *
215
+ * An empty host value is equivalent to removing the host.
216
+ *
217
+ * @param string $host The hostname to use with the new instance.
218
+ * @return self A new instance with the specified host.
219
+ * @throws \InvalidArgumentException for invalid hostnames.
220
+ */
221
+ public function withHost($host);
222
+
223
+ /**
224
+ * Return an instance with the specified port.
225
+ *
226
+ * This method MUST retain the state of the current instance, and return
227
+ * an instance that contains the specified port.
228
+ *
229
+ * Implementations MUST raise an exception for ports outside the
230
+ * established TCP and UDP port ranges.
231
+ *
232
+ * A null value provided for the port is equivalent to removing the port
233
+ * information.
234
+ *
235
+ * @param null|int $port The port to use with the new instance; a null value
236
+ * removes the port information.
237
+ * @return self A new instance with the specified port.
238
+ * @throws \InvalidArgumentException for invalid ports.
239
+ */
240
+ public function withPort($port);
241
+
242
+ /**
243
+ * Return an instance with the specified path.
244
+ *
245
+ * This method MUST retain the state of the current instance, and return
246
+ * an instance that contains the specified path.
247
+ *
248
+ * The path can either be empty or absolute (starting with a slash) or
249
+ * rootless (not starting with a slash). Implementations MUST support all
250
+ * three syntaxes.
251
+ *
252
+ * If the path is intended to be domain-relative rather than path relative then
253
+ * it must begin with a slash ("/"). Paths not starting with a slash ("/")
254
+ * are assumed to be relative to some base path known to the application or
255
+ * consumer.
256
+ *
257
+ * Users can provide both encoded and decoded path characters.
258
+ * Implementations ensure the correct encoding as outlined in getPath().
259
+ *
260
+ * @param string $path The path to use with the new instance.
261
+ * @return self A new instance with the specified path.
262
+ * @throws \InvalidArgumentException for invalid paths.
263
+ */
264
+ public function withPath($path);
265
+
266
+ /**
267
+ * Return an instance with the specified query string.
268
+ *
269
+ * This method MUST retain the state of the current instance, and return
270
+ * an instance that contains the specified query string.
271
+ *
272
+ * Users can provide both encoded and decoded query characters.
273
+ * Implementations ensure the correct encoding as outlined in getQuery().
274
+ *
275
+ * An empty query string value is equivalent to removing the query string.
276
+ *
277
+ * @param string $query The query string to use with the new instance.
278
+ * @return self A new instance with the specified query string.
279
+ * @throws \InvalidArgumentException for invalid query strings.
280
+ */
281
+ public function withQuery($query);
282
+
283
+ /**
284
+ * Return an instance with the specified URI fragment.
285
+ *
286
+ * This method MUST retain the state of the current instance, and return
287
+ * an instance that contains the specified URI fragment.
288
+ *
289
+ * Users can provide both encoded and decoded fragment characters.
290
+ * Implementations ensure the correct encoding as outlined in getFragment().
291
+ *
292
+ * An empty fragment value is equivalent to removing the fragment.
293
+ *
294
+ * @param string $fragment The fragment to use with the new instance.
295
+ * @return self A new instance with the specified fragment.
296
+ */
297
+ public function withFragment($fragment);
298
+
299
+ /**
300
+ * Return the string representation as a URI reference.
301
+ *
302
+ * Depending on which components of the URI are present, the resulting
303
+ * string is either a full URI or relative reference according to RFC 3986,
304
+ * Section 4.1. The method concatenates the various components of the URI,
305
+ * using the appropriate delimiters:
306
+ *
307
+ * - If a scheme is present, it MUST be suffixed by ":".
308
+ * - If an authority is present, it MUST be prefixed by "//".
309
+ * - The path can be concatenated without delimiters. But there are two
310
+ * cases where the path has to be adjusted to make the URI reference
311
+ * valid as PHP does not allow to throw an exception in __toString():
312
+ * - If the path is rootless and an authority is present, the path MUST
313
+ * be prefixed by "/".
314
+ * - If the path is starting with more than one "/" and no authority is
315
+ * present, the starting slashes MUST be reduced to one.
316
+ * - If a query is present, it MUST be prefixed by "?".
317
+ * - If a fragment is present, it MUST be prefixed by "#".
318
+ *
319
+ * @see http://tools.ietf.org/html/rfc3986#section-4.1
320
+ * @return string
321
+ */
322
+ public function __toString();
323
+ }
app/features/dlfile.php CHANGED
@@ -117,7 +117,7 @@ class MEC_feature_dlfile extends MEC_base
117
  });
118
  });
119
  </script>
120
- <div class="mec-meta-box-fields mec-event-tab-content" id="mec-downloadable-file">
121
  <h4><?php _e('Downloadable File', 'modern-events-calendar-lite'); ?></h4>
122
  <div id="mec_meta_box_downloadable_file_options">
123
  <input type="hidden" id="mec_downloadable_file" name="mec[downloadable_file]" value="<?php echo $file_id; ?>">
117
  });
118
  });
119
  </script>
120
+ <div class="mec-meta-box-fields mec-booking-tab-content" id="mec-downloadable-file">
121
  <h4><?php _e('Downloadable File', 'modern-events-calendar-lite'); ?></h4>
122
  <div id="mec_meta_box_downloadable_file_options">
123
  <input type="hidden" id="mec_downloadable_file" name="mec[downloadable_file]" value="<?php echo $file_id; ?>">
app/features/events.php CHANGED
@@ -352,7 +352,7 @@ class MEC_feature_events extends MEC_base
352
  __('Notifications', 'modern-events-calendar-lite') => 'mec-notifications',
353
  );
354
 
355
- $single_event_meta_title = apply_filters('mec-single-event-meta-title', $tabs, $activated);
356
 
357
  foreach($single_event_meta_title as $link_name => $link_address)
358
  {
@@ -1173,9 +1173,9 @@ class MEC_feature_events extends MEC_base
1173
 
1174
  <?php /** Dropdown **/ elseif($event_field['type'] == 'select'): ?>
1175
  <select id="mec_event_fields_<?php echo $j; ?>" name="mec[fields][<?php echo $j; ?>]" title="<?php esc_attr($event_field_name); ?>" <?php if(isset($event_field['mandatory']) and $event_field['mandatory']) echo 'required'; ?>>
1176
- <?php foreach($event_field['options'] as $event_field_option): ?>
1177
  <option value="<?php esc_attr_e($event_field_option['label'], 'modern-events-calendar-lite'); ?>" <?php echo ($event_field_option['label'] == $value ? 'selected="selected"' : ''); ?>><?php _e(stripslashes($event_field_option['label']), 'modern-events-calendar-lite'); ?></option>
1178
- <?php endforeach; ?>
1179
  </select>
1180
 
1181
  <?php /** Radio **/ elseif($event_field['type'] == 'radio'): ?>
@@ -1187,12 +1187,12 @@ class MEC_feature_events extends MEC_base
1187
  <?php endforeach; ?>
1188
 
1189
  <?php /** Checkbox **/ elseif($event_field['type'] == 'checkbox'): ?>
1190
- <?php foreach($event_field['options'] as $event_field_option): ?>
1191
  <label for="mec_event_fields_<?php echo $j.'_'.strtolower(str_replace(' ', '_', $event_field_option['label'])); ?>">
1192
  <input type="checkbox" id="mec_event_fields_<?php echo $j.'_'.strtolower(str_replace(' ', '_', $event_field_option['label'])); ?>" <?php echo ((is_array($value) and in_array($event_field_option['label'], $value)) ? 'checked="checked"' : ''); ?> name="mec[fields][<?php echo $j; ?>][]" value="<?php _e($event_field_option['label'], 'modern-events-calendar-lite'); ?>" />
1193
  <?php _e(stripslashes($event_field_option['label']), 'modern-events-calendar-lite'); ?>
1194
  </label>
1195
- <?php endforeach; ?>
1196
  <?php endif; ?>
1197
  </div>
1198
 
@@ -1614,6 +1614,7 @@ class MEC_feature_events extends MEC_base
1614
  $bookings_user_limit = isset($booking_options['bookings_user_limit']) ? $booking_options['bookings_user_limit'] : '';
1615
  $bookings_user_limit_unlimited = isset($booking_options['bookings_user_limit_unlimited']) ? $booking_options['bookings_user_limit_unlimited'] : true;
1616
  $bookings_all_occurrences = isset($booking_options['bookings_all_occurrences']) ? $booking_options['bookings_all_occurrences'] : 0;
 
1617
  ?>
1618
  <div id="mec-booking">
1619
  <div class="mec-meta-box-fields mec-booking-tab-content mec-tab-active" id="mec_meta_box_booking_options_form_1">
@@ -1646,6 +1647,19 @@ class MEC_feature_events extends MEC_base
1646
  <input class="mec-col-4 <?php echo ($bookings_limit_unlimited == 1) ? 'mec-util-hidden' : ''; ?>" type="text" name="mec[booking][bookings_limit]" id="mec_bookings_limit"
1647
  value="<?php echo esc_attr($bookings_limit); ?>" placeholder="<?php _e('100', 'modern-events-calendar-lite'); ?>"/>
1648
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
1649
  <h4 class="mec-title"><?php _e('Book All Occurrences', 'modern-events-calendar-lite'); ?></h4>
1650
  <div class="mec-form-row">
1651
  <label class="mec-col-4" for="mec_bookings_all_occurrences">
@@ -3297,6 +3311,9 @@ class MEC_feature_events extends MEC_base
3297
 
3298
  $mec_update = (isset($_REQUEST['original_publish']) and strtolower(trim($_REQUEST['original_publish'])) == 'publish') ? false : true;
3299
  do_action('mec_after_publish_admin_event', $post_id, $mec_update);
 
 
 
3300
  }
3301
 
3302
  public function quick_edit($post_id)
@@ -3339,6 +3356,7 @@ class MEC_feature_events extends MEC_base
3339
  {
3340
  $this->db->q("DELETE FROM `#__mec_events` WHERE `post_id`='$post_id'");
3341
  $this->db->q("DELETE FROM `#__mec_dates` WHERE `post_id`='$post_id'");
 
3342
 
3343
  return true;
3344
  }
352
  __('Notifications', 'modern-events-calendar-lite') => 'mec-notifications',
353
  );
354
 
355
+ $single_event_meta_title = apply_filters('mec-single-event-meta-title', $tabs, $activated, $post);
356
 
357
  foreach($single_event_meta_title as $link_name => $link_address)
358
  {
1173
 
1174
  <?php /** Dropdown **/ elseif($event_field['type'] == 'select'): ?>
1175
  <select id="mec_event_fields_<?php echo $j; ?>" name="mec[fields][<?php echo $j; ?>]" title="<?php esc_attr($event_field_name); ?>" <?php if(isset($event_field['mandatory']) and $event_field['mandatory']) echo 'required'; ?>>
1176
+ <?php if(isset($event_field['options']) and is_array($event_field['options'])): foreach($event_field['options'] as $event_field_option): ?>
1177
  <option value="<?php esc_attr_e($event_field_option['label'], 'modern-events-calendar-lite'); ?>" <?php echo ($event_field_option['label'] == $value ? 'selected="selected"' : ''); ?>><?php _e(stripslashes($event_field_option['label']), 'modern-events-calendar-lite'); ?></option>
1178
+ <?php endforeach; endif; ?>
1179
  </select>
1180
 
1181
  <?php /** Radio **/ elseif($event_field['type'] == 'radio'): ?>
1187
  <?php endforeach; ?>
1188
 
1189
  <?php /** Checkbox **/ elseif($event_field['type'] == 'checkbox'): ?>
1190
+ <?php if(isset($event_field['options']) and is_array($event_field['options'])): foreach($event_field['options'] as $event_field_option): ?>
1191
  <label for="mec_event_fields_<?php echo $j.'_'.strtolower(str_replace(' ', '_', $event_field_option['label'])); ?>">
1192
  <input type="checkbox" id="mec_event_fields_<?php echo $j.'_'.strtolower(str_replace(' ', '_', $event_field_option['label'])); ?>" <?php echo ((is_array($value) and in_array($event_field_option['label'], $value)) ? 'checked="checked"' : ''); ?> name="mec[fields][<?php echo $j; ?>][]" value="<?php _e($event_field_option['label'], 'modern-events-calendar-lite'); ?>" />
1193
  <?php _e(stripslashes($event_field_option['label']), 'modern-events-calendar-lite'); ?>
1194
  </label>
1195
+ <?php endforeach; endif; ?>
1196
  <?php endif; ?>
1197
  </div>
1198
 
1614
  $bookings_user_limit = isset($booking_options['bookings_user_limit']) ? $booking_options['bookings_user_limit'] : '';
1615
  $bookings_user_limit_unlimited = isset($booking_options['bookings_user_limit_unlimited']) ? $booking_options['bookings_user_limit_unlimited'] : true;
1616
  $bookings_all_occurrences = isset($booking_options['bookings_all_occurrences']) ? $booking_options['bookings_all_occurrences'] : 0;
1617
+ $loggedin_discount = isset($booking_options['loggedin_discount']) ? $booking_options['loggedin_discount'] : '';
1618
  ?>
1619
  <div id="mec-booking">
1620
  <div class="mec-meta-box-fields mec-booking-tab-content mec-tab-active" id="mec_meta_box_booking_options_form_1">
1647
  <input class="mec-col-4 <?php echo ($bookings_limit_unlimited == 1) ? 'mec-util-hidden' : ''; ?>" type="text" name="mec[booking][bookings_limit]" id="mec_bookings_limit"
1648
  value="<?php echo esc_attr($bookings_limit); ?>" placeholder="<?php _e('100', 'modern-events-calendar-lite'); ?>"/>
1649
  </div>
1650
+ <h4 class="mec-title"><label for="mec_bookings_loggedin_discount"><?php _e('Discount for loggedin members', 'modern-events-calendar-lite'); ?></label></h4>
1651
+ <div class="mec-form-row">
1652
+ <input class="mec-col-4" type="text" name="mec[booking][loggedin_discount]" id="mec_bookings_loggedin_discount" value="<?php echo esc_attr($loggedin_discount); ?>" placeholder="<?php _e('5', 'modern-events-calendar-lite'); ?>">
1653
+ <span class="mec-tooltip">
1654
+ <div class="box">
1655
+ <h5 class="title"><?php _e('Loggedin members discount', 'modern-events-calendar-lite'); ?></h5>
1656
+ <div class="content">
1657
+ <p><?php echo sprintf(esc_html__("You can provide a discount to loggedin users for %s prices. The discount is in percentage."), '<strong>'.__('tickets', 'modern-events-calendar-lite').'</strong>'); ?></p>
1658
+ </div>
1659
+ </div>
1660
+ <i title="" class="dashicons-before dashicons-editor-help"></i>
1661
+ </span>
1662
+ </div>
1663
  <h4 class="mec-title"><?php _e('Book All Occurrences', 'modern-events-calendar-lite'); ?></h4>
1664
  <div class="mec-form-row">
1665
  <label class="mec-col-4" for="mec_bookings_all_occurrences">
3311
 
3312
  $mec_update = (isset($_REQUEST['original_publish']) and strtolower(trim($_REQUEST['original_publish'])) == 'publish') ? false : true;
3313
  do_action('mec_after_publish_admin_event', $post_id, $mec_update);
3314
+
3315
+ // Save Event Data
3316
+ do_action('mec_save_event_data', $post_id, $_mec);
3317
  }
3318
 
3319
  public function quick_edit($post_id)
3356
  {
3357
  $this->db->q("DELETE FROM `#__mec_events` WHERE `post_id`='$post_id'");
3358
  $this->db->q("DELETE FROM `#__mec_dates` WHERE `post_id`='$post_id'");
3359
+ $this->db->q("DELETE FROM `#__mec_occurrences` WHERE `post_id`='$post_id'");
3360
 
3361
  return true;
3362
  }
app/features/fes.php CHANGED
@@ -208,7 +208,7 @@ class MEC_feature_fes extends MEC_base
208
 
209
  if($timestamp)
210
  {
211
- $bookings = $this->main->get_bookings(get_the_ID(), $timestamp);
212
  foreach($bookings as $booking)
213
  {
214
  $booking_ids .= $booking->ID.',';
@@ -220,7 +220,7 @@ class MEC_feature_fes extends MEC_base
220
  if(!count($post_ids))
221
  {
222
  $books = $this->db->select("SELECT `post_id` FROM `#__postmeta` WHERE `meta_key`='mec_event_id' AND `meta_value`={$event_id}", 'loadAssocList');
223
- foreach ($books as $book) if(isset($book['post_id'])) $post_ids[] = $book['post_id'];
224
  }
225
 
226
  $event_ids = array();
@@ -1256,6 +1256,9 @@ class MEC_feature_fes extends MEC_base
1256
  // Trigger Event
1257
  if($method == 'updated') do_action('mec_fes_updated', $post_id , 'update');
1258
  else do_action('mec_fes_added', $post_id , '');
 
 
 
1259
 
1260
  $this->main->response(array(
1261
  'success' => 1,
208
 
209
  if($timestamp)
210
  {
211
+ $bookings = $this->main->get_bookings($event_id, $timestamp);
212
  foreach($bookings as $booking)
213
  {
214
  $booking_ids .= $booking->ID.',';
220
  if(!count($post_ids))
221
  {
222
  $books = $this->db->select("SELECT `post_id` FROM `#__postmeta` WHERE `meta_key`='mec_event_id' AND `meta_value`={$event_id}", 'loadAssocList');
223
+ foreach($books as $book) if(isset($book['post_id'])) $post_ids[] = $book['post_id'];
224
  }
225
 
226
  $event_ids = array();
1256
  // Trigger Event
1257
  if($method == 'updated') do_action('mec_fes_updated', $post_id , 'update');
1258
  else do_action('mec_fes_added', $post_id , '');
1259
+
1260
+ // Save Event Data
1261
+ do_action('mec_save_event_data', $post_id, $mec);
1262
 
1263
  $this->main->response(array(
1264
  'success' => 1,
app/features/ix.php CHANGED
@@ -3126,7 +3126,7 @@ class MEC_feature_ix extends MEC_base
3126
 
3127
  $rule[$key] = $value;
3128
  }
3129
-
3130
  $interval = NULL;
3131
  $year = NULL;
3132
  $month = NULL;
@@ -3134,6 +3134,8 @@ class MEC_feature_ix extends MEC_base
3134
  $week = NULL;
3135
  $weekday = NULL;
3136
  $weekdays = NULL;
 
 
3137
 
3138
  if($rule['freq'] == 'daily')
3139
  {
@@ -3145,6 +3147,25 @@ class MEC_feature_ix extends MEC_base
3145
  $repeat_type = 'weekly';
3146
  $interval = isset($rule['interval']) ? $rule['interval']*7 : 7;
3147
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3148
  elseif($rule['freq'] == 'monthly')
3149
  {
3150
  $repeat_type = 'monthly';
@@ -3241,6 +3262,7 @@ class MEC_feature_ix extends MEC_base
3241
  $week = NULL;
3242
  $weekday = NULL;
3243
  $weekdays = NULL;
 
3244
  }
3245
 
3246
  $args = array
@@ -3294,7 +3316,8 @@ class MEC_feature_ix extends MEC_base
3294
  'mec_gcal_id'=>$gcal_id,
3295
  'mec_gcal_calendar_id'=>$calendar_id,
3296
  'mec_g_recurrence_rule'=>$g_recurrence_rule,
3297
- 'mec_allday'=>$allday
 
3298
  )
3299
  );
3300
 
@@ -3940,34 +3963,26 @@ class MEC_feature_ix extends MEC_base
3940
 
3941
  $dates = $render->dates($mec_event_id, $data);
3942
  $date = isset($dates[0]) ? $dates[0] : array();
3943
-
3944
  $location = isset($data->locations[$data->meta['mec_location_id']]) ? $data->locations[$data->meta['mec_location_id']] : array();
3945
  $organizer = isset($data->organizers[$data->meta['mec_organizer_id']]) ? $data->organizers[$data->meta['mec_organizer_id']] : array();
3946
 
3947
  $recurrence = $this->main->get_ical_rrules($data);
3948
 
3949
- $start_time = sprintf("%02d", $data->meta['mec_start_time_hour']).':';
3950
- $start_time .= sprintf("%02d", $data->meta['mec_start_time_minutes']).' ';
3951
- $start_time .= $data->meta['mec_start_time_ampm'];
3952
-
3953
  $start = array(
3954
- 'dateTime'=>date('Y-m-d\TH:i:s', strtotime($date['start']['date'].' '.$start_time)).$gmt_offset,
3955
  'timeZone'=>$timezone,
3956
  );
3957
 
3958
- $end_time = sprintf("%02d", $data->meta['mec_end_time_hour']).':';
3959
- $end_time .= sprintf("%02d", $data->meta['mec_end_time_minutes']).' ';
3960
- $end_time .= $data->meta['mec_end_time_ampm'];
3961
-
3962
  $end = array(
3963
- 'dateTime'=>date('Y-m-d\TH:i:s', strtotime($date['end']['date'].' '.$end_time)).$gmt_offset,
3964
  'timeZone'=>$timezone,
3965
  );
3966
 
3967
  $allday = isset($data->meta['mec_allday']) ? $data->meta['mec_allday'] : 0;
3968
  if($allday)
3969
  {
3970
- $start['dateTime'] = date('Y-m-d\T00:00:00', strtotime($start['dateTime'])).$gmt_offset;
3971
  $end['dateTime'] = date('Y-m-d\T00:00:00', strtotime('+1 Day', strtotime($end['dateTime']))).$gmt_offset;
3972
  }
3973
 
3126
 
3127
  $rule[$key] = $value;
3128
  }
3129
+
3130
  $interval = NULL;
3131
  $year = NULL;
3132
  $month = NULL;
3134
  $week = NULL;
3135
  $weekday = NULL;
3136
  $weekdays = NULL;
3137
+ $weekdays = NULL;
3138
+ $advanced_days = NULL;
3139
 
3140
  if($rule['freq'] == 'daily')
3141
  {
3147
  $repeat_type = 'weekly';
3148
  $interval = isset($rule['interval']) ? $rule['interval']*7 : 7;
3149
  }
3150
+ elseif($rule['freq'] == 'monthly' and isset($rule['byday']) and trim($rule['byday']))
3151
+ {
3152
+ $repeat_type = 'advanced';
3153
+
3154
+ $adv_week = (isset($rule['bysetpos']) and trim($rule['bysetpos']) != '') ? $rule['bysetpos'] : (int) substr($rule['byday'], 0, -2);
3155
+ if($adv_week < 0) $adv_week = 'l';
3156
+
3157
+ $adv_day = str_replace($adv_week, '', $rule['byday']);
3158
+
3159
+ $mec_adv_day = 'Sat';
3160
+ if($adv_day == 'su') $mec_adv_day = 'Sun';
3161
+ elseif($adv_day == 'mo') $mec_adv_day = 'Mon';
3162
+ elseif($adv_day == 'tu') $mec_adv_day = 'Tue';
3163
+ elseif($adv_day == 'we') $mec_adv_day = 'Wed';
3164
+ elseif($adv_day == 'th') $mec_adv_day = 'Thu';
3165
+ elseif($adv_day == 'fr') $mec_adv_day = 'Fri';
3166
+
3167
+ $advanced_days = array($mec_adv_day.'.'.$adv_week);
3168
+ }
3169
  elseif($rule['freq'] == 'monthly')
3170
  {
3171
  $repeat_type = 'monthly';
3262
  $week = NULL;
3263
  $weekday = NULL;
3264
  $weekdays = NULL;
3265
+ $advanced_days = NULL;
3266
  }
3267
 
3268
  $args = array
3316
  'mec_gcal_id'=>$gcal_id,
3317
  'mec_gcal_calendar_id'=>$calendar_id,
3318
  'mec_g_recurrence_rule'=>$g_recurrence_rule,
3319
+ 'mec_allday'=>$allday,
3320
+ 'mec_advanced_days'=>$advanced_days,
3321
  )
3322
  );
3323
 
3963
 
3964
  $dates = $render->dates($mec_event_id, $data);
3965
  $date = isset($dates[0]) ? $dates[0] : array();
3966
+
3967
  $location = isset($data->locations[$data->meta['mec_location_id']]) ? $data->locations[$data->meta['mec_location_id']] : array();
3968
  $organizer = isset($data->organizers[$data->meta['mec_organizer_id']]) ? $data->organizers[$data->meta['mec_organizer_id']] : array();
3969
 
3970
  $recurrence = $this->main->get_ical_rrules($data);
3971
 
 
 
 
 
3972
  $start = array(
3973
+ 'dateTime'=>date('Y-m-d\TH:i:s', $date['start']['timestamp']).$gmt_offset,
3974
  'timeZone'=>$timezone,
3975
  );
3976
 
 
 
 
 
3977
  $end = array(
3978
+ 'dateTime'=>date('Y-m-d\TH:i:s', $date['end']['timestamp']).$gmt_offset,
3979
  'timeZone'=>$timezone,
3980
  );
3981
 
3982
  $allday = isset($data->meta['mec_allday']) ? $data->meta['mec_allday'] : 0;
3983
  if($allday)
3984
  {
3985
+ $start['dateTime'] = date('Y-m-d\T00:00:00', $date['start']['timestamp']).$gmt_offset;
3986
  $end['dateTime'] = date('Y-m-d\T00:00:00', strtotime('+1 Day', strtotime($end['dateTime']))).$gmt_offset;
3987
  }
3988
 
app/features/labels.php CHANGED
@@ -236,7 +236,7 @@ class MEC_feature_labels extends MEC_base
236
  <?php foreach($labels as $label): ?>
237
  <div class="mec-label-row">
238
  <input <?php if(in_array($label->term_id, $terms)) echo 'checked="checked"'; ?> name="mec[labels][]" type="checkbox" value="<?php echo $label->term_id; ?>" id="mec_label<?php echo $label->term_id; ?>" />
239
- <?php do_action('mec_label_to_checkbox_backend',$label, $terms ); ?>
240
  <label for="mec_label<?php echo $label->term_id; ?>"><?php echo $label->name; ?></label>
241
  <span class="mec-color" style="background-color: <?php echo get_term_meta($label->term_id, 'color', true); ?>"></span>
242
  </div>
236
  <?php foreach($labels as $label): ?>
237
  <div class="mec-label-row">
238
  <input <?php if(in_array($label->term_id, $terms)) echo 'checked="checked"'; ?> name="mec[labels][]" type="checkbox" value="<?php echo $label->term_id; ?>" id="mec_label<?php echo $label->term_id; ?>" />
239
+ <?php do_action('mec_label_to_checkbox_backend', $label, $terms ); ?>
240
  <label for="mec_label<?php echo $label->term_id; ?>"><?php echo $label->name; ?></label>
241
  <span class="mec-color" style="background-color: <?php echo get_term_meta($label->term_id, 'color', true); ?>"></span>
242
  </div>
app/features/mec.php CHANGED
@@ -1202,39 +1202,86 @@ class MEC_feature_mec extends MEC_base
1202
  }
1203
 
1204
  echo '</ul></div>';
 
 
1205
 
1206
- $data_url = 'https://webnus.net/wp-json/wninfo/v1/posts';
1207
- if(function_exists('file_get_contents') && ini_get('allow_url_fopen'))
1208
- {
1209
- $ctx = stream_context_create(array('http'=>
1210
- array(
1211
- 'timeout' => 20,
1212
- )
1213
- ));
1214
-
1215
- $get_data = file_get_contents($data_url, false, $ctx);
1216
- if($get_data !== false and !empty($get_data))
1217
  {
1218
- $obj = json_decode($get_data);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1219
  }
1220
  }
1221
- elseif(function_exists('curl_version'))
1222
- {
1223
- $ch = curl_init();
1224
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
1225
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
1226
- curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 0);
1227
- curl_setopt($ch, CURLOPT_TIMEOUT, 20); //timeout in seconds
1228
- curl_setopt($ch, CURLOPT_URL, $data_url);
1229
-
1230
- $result = curl_exec($ch);
1231
- curl_close($ch);
1232
- $obj = json_decode($result);
1233
- }
1234
- else
1235
- {
1236
- $obj = '';
1237
- }
1238
 
1239
  // News
1240
  if(!empty($obj))
1202
  }
1203
 
1204
  echo '</ul></div>';
1205
+ $mec_get_webnus_news_time = get_option('mec_get_webnus_news_time');
1206
+ $mec_get_webnus_news_html = get_option('mec_get_webnus_news_html');
1207
 
1208
+ if ( !isset($mec_get_webnus_news_time)) {
1209
+ $data_url = 'https://webnus.net/wp-json/wninfo/v1/posts';
1210
+ if(function_exists('file_get_contents') && ini_get('allow_url_fopen'))
 
 
 
 
 
 
 
 
1211
  {
1212
+ $ctx = stream_context_create(array('http'=>
1213
+ array(
1214
+ 'timeout' => 20,
1215
+ )
1216
+ ));
1217
+
1218
+ $get_data = file_get_contents($data_url, false, $ctx);
1219
+ if($get_data !== false and !empty($get_data))
1220
+ {
1221
+ $obj = json_decode($get_data);
1222
+ }
1223
+ }
1224
+ elseif(function_exists('curl_version'))
1225
+ {
1226
+ $ch = curl_init();
1227
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
1228
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
1229
+ curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 0);
1230
+ curl_setopt($ch, CURLOPT_TIMEOUT, 20); //timeout in seconds
1231
+ curl_setopt($ch, CURLOPT_URL, $data_url);
1232
+
1233
+ $result = curl_exec($ch);
1234
+ curl_close($ch);
1235
+ $obj = json_decode($result);
1236
+ }
1237
+ else
1238
+ {
1239
+ $obj = '';
1240
+ }
1241
+ update_option('mec_get_webnus_news_time', date("Y-m-d"));
1242
+ update_option('mec_get_webnus_news_html', $obj);
1243
+ } else {
1244
+ if ( strtotime(date("Y-m-d")) > strtotime($mec_get_webnus_news_time) ) {
1245
+ $data_url = 'https://webnus.net/wp-json/wninfo/v1/posts';
1246
+ if(function_exists('file_get_contents') && ini_get('allow_url_fopen'))
1247
+ {
1248
+ $ctx = stream_context_create(array('http'=>
1249
+ array(
1250
+ 'timeout' => 20,
1251
+ )
1252
+ ));
1253
+
1254
+ $get_data = file_get_contents($data_url, false, $ctx);
1255
+ if($get_data !== false and !empty($get_data))
1256
+ {
1257
+ $obj = json_decode($get_data);
1258
+ }
1259
+ }
1260
+ elseif(function_exists('curl_version'))
1261
+ {
1262
+ $ch = curl_init();
1263
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
1264
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
1265
+ curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 0);
1266
+ curl_setopt($ch, CURLOPT_TIMEOUT, 20); //timeout in seconds
1267
+ curl_setopt($ch, CURLOPT_URL, $data_url);
1268
+
1269
+ $result = curl_exec($ch);
1270
+ curl_close($ch);
1271
+ $obj = json_decode($result);
1272
+ }
1273
+ else
1274
+ {
1275
+ $obj = '';
1276
+ }
1277
+ update_option('mec_get_webnus_news_time', date("Y-m-d"));
1278
+ update_option('mec_get_webnus_news_html', $obj);
1279
+ } else {
1280
+ $obj = get_option('mec_get_webnus_news_html');
1281
  }
1282
  }
1283
+
1284
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1285
 
1286
  // News
1287
  if(!empty($obj))
app/features/mec/booking.php CHANGED
@@ -106,6 +106,7 @@ $gateways_options = $this->main->get_gateways_options();
106
  </label>
107
  </div>
108
  <div id="mec_booking_container_toggle" class="<?php if((isset($settings['booking_status']) and !$settings['booking_status']) or !isset($settings['booking_status'])) echo 'mec-util-hidden'; ?>">
 
109
  <div class="mec-form-row">
110
  <label class="mec-col-3" for="mec_settings_booking_date_format1"><?php _e('Date Format', 'modern-events-calendar-lite'); ?></label>
111
  <div class="mec-col-4">
@@ -119,41 +120,13 @@ $gateways_options = $this->main->get_gateways_options();
119
  </span>
120
  </div>
121
  </div>
122
- <div class="mec-form-row">
123
- <label class="mec-col-3" for="mec_settings_booking_limit"><?php _e('Limit', 'modern-events-calendar-lite'); ?></label>
124
- <div class="mec-col-4">
125
- <input type="number" id="mec_settings_booking_limit" name="mec[settings][booking_limit]" value="<?php echo ((isset($settings['booking_limit']) and trim($settings['booking_limit']) != '') ? $settings['booking_limit'] : ''); ?>" placeholder="<?php esc_attr_e('Default is empty', 'modern-events-calendar-lite'); ?>" />
126
- <span class="mec-tooltip">
127
- <div class="box">
128
- <h5 class="title"><?php _e('Booking Limit', 'modern-events-calendar-lite'); ?></h5>
129
- <div class="content"><p><?php esc_attr_e("Total tickets that a user can book. It is useful if you're providing free tickets. Leave it empty for unlimited booking.", 'modern-events-calendar-lite'); ?></p></div>
130
- </div>
131
- <i title="" class="dashicons-before dashicons-editor-help"></i>
132
- </span>
133
- </div>
134
- </div>
135
- <div class="mec-form-row">
136
- <label class="mec-col-3" for="mec_settings_booking_ip_restriction"><?php _e('IP restriction', 'modern-events-calendar-lite'); ?></label>
137
- <div class="mec-col-4">
138
- <select id="mec_settings_booking_ip_restriction" name="mec[settings][booking_ip_restriction]">
139
- <option value="1" <?php echo ((isset($settings['booking_ip_restriction']) and trim($settings['booking_ip_restriction']) == 1) ? 'selected="selected"' : ''); ?>><?php echo esc_html__('Enabled', 'modern-events-calendar-lite'); ?></option>
140
- <option value="0" <?php echo ((isset($settings['booking_ip_restriction']) and trim($settings['booking_ip_restriction']) == 0) ? 'selected="selected"' : ''); ?>><?php echo esc_html__('Disabled', 'modern-events-calendar-lite'); ?></option>
141
- </select>
142
- <span class="mec-tooltip">
143
- <div class="box">
144
- <h5 class="title"><?php _e('IP restriction', 'modern-events-calendar-lite'); ?></h5>
145
- <div class="content"><p><?php esc_attr_e("If you set limit for total tickets that users can book, MEC will use IP and email to prevent users to book high tickets. You can disable the IP restriction if you don't need it.", 'modern-events-calendar-lite'); ?></p></div>
146
- </div>
147
- <i title="" class="dashicons-before dashicons-editor-help"></i>
148
- </span>
149
- </div>
150
- </div>
151
  <div class="mec-form-row">
152
  <label class="mec-col-3" for="mec_settings_booking_maximum_dates"><?php _e('Maximum Dates', 'modern-events-calendar-lite'); ?></label>
153
  <div class="mec-col-4">
154
  <input type="number" id="mec_settings_booking_maximum_dates" name="mec[settings][booking_maximum_dates]" value="<?php echo ((isset($settings['booking_maximum_dates']) and trim($settings['booking_maximum_dates']) != '') ? $settings['booking_maximum_dates'] : '6'); ?>" placeholder="<?php esc_attr_e('Default is 6', 'modern-events-calendar-lite'); ?>" min="1" />
155
  </div>
156
  </div>
 
157
  <div class="mec-form-row">
158
  <label class="mec-col-3" for="mec_settings_show_booking_form_interval"><?php _e('Show Booking Form Interval', 'modern-events-calendar-lite'); ?></label>
159
  <div class="mec-col-4">
@@ -189,55 +162,89 @@ $gateways_options = $this->main->get_gateways_options();
189
  </span>
190
  </div>
191
  </div>
 
192
  <div class="mec-form-row">
193
- <label class="mec-col-3" for="mec_settings_booking_thankyou_page"><?php _e('Thank You Page', 'modern-events-calendar-lite'); ?></label>
194
  <div class="mec-col-4">
195
- <select id="mec_settings_booking_thankyou_page" name="mec[settings][booking_thankyou_page]">
196
  <option value="">----</option>
197
- <?php foreach($pages as $page): ?>
198
- <option <?php echo ((isset($settings['booking_thankyou_page']) and $settings['booking_thankyou_page'] == $page->ID) ? 'selected="selected"' : ''); ?> value="<?php echo $page->ID; ?>"><?php echo $page->post_title; ?></option>
199
  <?php endforeach; ?>
200
  </select>
201
  <span class="m
106
  </label>
107
  </div>
108
  <div id="mec_booking_container_toggle" class="<?php if((isset($settings['booking_status']) and !$settings['booking_status']) or !isset($settings['booking_status'])) echo 'mec-util-hidden'; ?>">
109
+ <h5 class="title"><?php _e('Date Options', 'modern-events-calendar-lite'); ?></h5>
110
  <div class="mec-form-row">
111
  <label class="mec-col-3" for="mec_settings_booking_date_format1"><?php _e('Date Format', 'modern-events-calendar-lite'); ?></label>
112
  <div class="mec-col-4">
120
  </span>
121
  </div>
122
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
123
  <div class="mec-form-row">
124
  <label class="mec-col-3" for="mec_settings_booking_maximum_dates"><?php _e('Maximum Dates', 'modern-events-calendar-lite'); ?></label>
125
  <div class="mec-col-4">
126
  <input type="number" id="mec_settings_booking_maximum_dates" name="mec[settings][booking_maximum_dates]" value="<?php echo ((isset($settings['booking_maximum_dates']) and trim($settings['booking_maximum_dates']) != '') ? $settings['booking_maximum_dates'] : '6'); ?>" placeholder="<?php esc_attr_e('Default is 6', 'modern-events-calendar-lite'); ?>" min="1" />
127
  </div>
128
  </div>
129
+ <h5 class="title"><?php _e('Interval Options', 'modern-events-calendar-lite'); ?></h5>
130
  <div class="mec-form-row">
131
  <label class="mec-col-3" for="mec_settings_show_booking_form_interval"><?php _e('Show Booking Form Interval', 'modern-events-calendar-lite'); ?></label>
132
  <div class="mec-col-4">
162
  </span>
163
  </div>
164
  </div>
165
+ <h5 class="title"><?php _e('User Role', 'modern-events-calendar-lite'); ?></h5>
166
  <div class="mec-form-row">
167
+ <label class="mec-col-3" for="mec_settings_booking_user_role"><?php _e('User Role', 'modern-events-calendar-lite'); ?></label>
168
  <div class="mec-col-4">
169
+ <select id="mec_settings_booking_user_role" name="mec[settings][booking_user_role]">
170
  <option value="">----</option>
171
+ <?php foreach($roles as $role => $r): ?>
172
+ <option <?php echo ((isset($settings['booking_user_role']) and $settings['booking_user_role'] == $role) ? 'selected="selected"' : ''); ?> value="<?php echo $role; ?>"><?php echo $r['name']; ?></option>
173
  <?php endforeach; ?>
174
  </select>
175
  <span class="m