Completed
Push — master ( 50a9e6...dccb70 )
by Steven
02:20
created

AuthorizationTrait::getHttp()

Size

Total Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 1
ccs 0
cts 0
cp 0
c 0
b 0
f 0
nc 1
1
<?php namespace Stevenmaguire\Services\Trello\Traits;
2
3
use League\OAuth1\Client\Credentials\TemporaryCredentials;
4
5
trait AuthorizationTrait
6
{
7
    /**
8
     * Retrieves currently configured authorization broker.
9
     *
10
     * @return Stevenmaguire\Services\Trello\Authorization
11
     * @codeCoverageIgnore
12
     */
13
    abstract public function getAuthorization();
14
15
    /**
16
     * Retrieves currently configured http broker.
17
     *
18
     * @return Stevenmaguire\Services\Trello\Http
19
     * @codeCoverageIgnore
20
     */
21
    abstract public function getHttp();
22
23
    /**
24
     * Retrieves http response from Trello api for authorization.
25
     *
26
     * @param  array $attributes
27
     *
28
     * @return object
29
     */
30 2
    public function getAuthorize($attributes = [])
31
    {
32 2
        return $this->getHttp()->get('authorize', $attributes);
33
    }
34
35
    /**
36
     * Retrieves complete authorization url.
37
     *
38
     * @param  League\OAuth1\Client\Credentials\TemporaryCredentials   $temporaryCredentials
39
     *
40
     * @return string
41
     */
42 4
    public function getAuthorizationUrl(TemporaryCredentials $temporaryCredentials = null)
43
    {
44 4
        return $this->getAuthorization()->getAuthorizationUrl($temporaryCredentials);
45
    }
46
47
    /**
48
     * Retrives access token credentials with token and verifier.
49
     *
50
     * @param  string                                                  $token
51
     * @param  string                                                  $verifier
52
     * @param  League\OAuth1\Client\Credentials\TemporaryCredentials   $temporaryCredentials
53
     *
54
     * @return League\OAuth1\Client\Credentials\CredentialsInterface
55
     */
56 4
    public function getAccessToken($token, $verifier, TemporaryCredentials $temporaryCredentials = null)
57
    {
58 4
        return $this->getAuthorization()->getToken($token, $verifier, $temporaryCredentials);
59
    }
60
61
    /**
62
     * Creates and returns new temporary credentials instance.
63
     *
64
     * @return League\OAuth1\Client\Credentials\CredentialsInterface
65
     */
66 2
    public function getTemporaryCredentials()
67
    {
68 2
        return $this->getAuthorization()->getTemporaryCredentials();
69
    }
70
}
71