1 | <?php |
||
11 | class OAuth1 implements OAuth1Interface |
||
12 | { |
||
13 | /** |
||
14 | * The RequestConfigInterface instance. |
||
15 | * |
||
16 | * @var \Risan\OAuth1\Request\RequestConfigInterface |
||
17 | */ |
||
18 | protected $requestConfig; |
||
19 | |||
20 | /** |
||
21 | * The HttpClientInterface instance. |
||
22 | * |
||
23 | * @var \Risan\OAuth1\HttpClientInterface |
||
24 | */ |
||
25 | protected $httpClient; |
||
26 | |||
27 | /** |
||
28 | * The CredentialsFactoryInterface instance. |
||
29 | * |
||
30 | * @var \Risan\OAuth1\Credentials\CredentialsFactoryInterface |
||
31 | */ |
||
32 | protected $credentialsFactory; |
||
33 | |||
34 | /** |
||
35 | * Create a new OAuth1 instance. |
||
36 | * |
||
37 | * @param \Risan\OAuth1\Request\RequestConfigInterface $requestConfig |
||
38 | * @param \Risan\OAuth1\HttpClientInterface $httpClient |
||
39 | * @param \Risan\OAuth1\Credentials\CredentialsFactoryInterface $credentialsFactory |
||
40 | */ |
||
41 | 7 | public function __construct(RequestConfigInterface $requestConfig, HttpClientInterface $httpClient, CredentialsFactoryInterface $credentialsFactory) |
|
42 | { |
||
43 | 7 | $this->requestConfig = $requestConfig; |
|
44 | 7 | $this->httpClient = $httpClient; |
|
45 | 7 | $this->credentialsFactory = $credentialsFactory; |
|
46 | 7 | } |
|
47 | |||
48 | /** |
||
49 | * {@inheritDoc} |
||
50 | */ |
||
51 | 1 | public function getRequestConfig() |
|
52 | { |
||
53 | 1 | return $this->requestConfig; |
|
54 | } |
||
55 | |||
56 | /** |
||
57 | * {@inheritDoc} |
||
58 | */ |
||
59 | 1 | public function getHttpClient() |
|
60 | { |
||
61 | 1 | return $this->httpClient; |
|
62 | } |
||
63 | |||
64 | /** |
||
65 | * {@inheritDoc} |
||
66 | */ |
||
67 | 1 | public function getCredentialsFactory() |
|
71 | |||
72 | /** |
||
73 | * {@inheritDoc} |
||
74 | */ |
||
75 | 1 | public function getTemporaryCredentials() |
|
76 | { |
||
77 | 1 | $response = $this->httpClient->post($this->requestConfig->getTemporaryCredentialsUrl(), [ |
|
78 | 'headers' => [ |
||
79 | 1 | 'Authorization' => $this->requestConfig->getTemporaryCredentialsAuthorizationHeader(), |
|
80 | ], |
||
81 | ]); |
||
82 | |||
83 | 1 | return $this->credentialsFactory->createTemporaryCredentialsFromResponse($response); |
|
84 | } |
||
85 | |||
86 | /** |
||
87 | * {@inheritDoc} |
||
88 | */ |
||
89 | 1 | public function buildAuthorizationUrl(TemporaryCredentials $temporaryCredentials) |
|
93 | |||
94 | /** |
||
95 | * {@inheritDoc} |
||
96 | */ |
||
97 | public function getTokenCredentials(TemporaryCredentials $temporaryCredentials, $temporaryIdentifier, $verificationCode) |
||
114 | } |
||
115 |