1 | <?php |
||
19 | class JawboneUP extends AbstractService |
||
20 | { |
||
21 | /** |
||
22 | * Defined scopes |
||
23 | * |
||
24 | * |
||
25 | * @link https://jawbone.com/up/developer/authentication |
||
26 | */ |
||
27 | // general information scopes |
||
28 | const SCOPE_BASIC_READ = 'basic_read'; |
||
29 | const SCOPE_EXTENDED_READ = 'extended_read'; |
||
30 | const SCOPE_LOCATION_READ = 'location_read'; |
||
31 | const SCOPE_FRIENDS_READ = 'friends_read'; |
||
32 | // mood scopes |
||
33 | const SCOPE_MOOD_READ = 'mood_read'; |
||
34 | const SCOPE_MOOD_WRITE = 'mood_write'; |
||
35 | // move scopes |
||
36 | const SCOPE_MOVE_READ = 'move_read'; |
||
37 | const SCOPE_MOVE_WRITE = 'move_write'; |
||
38 | // sleep scopes |
||
39 | const SCOPE_SLEEP_READ = 'sleep_read'; |
||
40 | const SCOPE_SLEEP_WRITE = 'sleep_write'; |
||
41 | // meal scopes |
||
42 | const SCOPE_MEAL_READ = 'meal_read'; |
||
43 | const SCOPE_MEAL_WRITE = 'meal_write'; |
||
44 | // weight scopes |
||
45 | const SCOPE_WEIGHT_READ = 'weight_read'; |
||
46 | const SCOPE_WEIGHT_WRITE = 'weight_write'; |
||
47 | // generic event scopes |
||
48 | const SCOPE_GENERIC_EVENT_READ = 'generic_event_read'; |
||
49 | const SCOPE_GENERIC_EVENT_WRITE = 'generic_event_write'; |
||
50 | |||
51 | |||
52 | public function __construct( |
||
53 | CredentialsInterface $credentials, |
||
54 | ClientInterface $httpClient, |
||
55 | TokenStorageInterface $storage, |
||
56 | $scopes = array(), |
||
57 | UriInterface $baseApiUri = null |
||
58 | ) { |
||
59 | parent::__construct($credentials, $httpClient, $storage, $scopes, $baseApiUri); |
||
60 | |||
61 | if (null === $baseApiUri) { |
||
62 | $this->baseApiUri = new Uri('https://jawbone.com/nudge/api/v.1.1/'); |
||
63 | } |
||
64 | } |
||
65 | |||
66 | /** |
||
67 | * {@inheritdoc} |
||
68 | */ |
||
69 | public function getAuthorizationUri(array $additionalParameters = array()) |
||
70 | { |
||
71 | $parameters = array_merge( |
||
72 | $additionalParameters, |
||
73 | array( |
||
74 | 'client_id' => $this->credentials->getConsumerId(), |
||
75 | 'redirect_uri' => $this->credentials->getCallbackUrl(), |
||
76 | 'response_type' => 'code', |
||
77 | ) |
||
78 | ); |
||
79 | |||
80 | $parameters['scope'] = implode(' ', $this->scopes); |
||
81 | |||
82 | // Build the url |
||
83 | $url = clone $this->getAuthorizationEndpoint(); |
||
84 | foreach ($parameters as $key => $val) { |
||
85 | $url->addToQuery($key, $val); |
||
86 | } |
||
87 | |||
88 | return $url; |
||
89 | } |
||
90 | |||
91 | /** |
||
92 | * {@inheritdoc} |
||
93 | */ |
||
94 | public function getAuthorizationEndpoint() |
||
98 | |||
99 | /** |
||
100 | * {@inheritdoc} |
||
101 | */ |
||
102 | public function getAccessTokenEndpoint() |
||
106 | |||
107 | /** |
||
108 | * {@inheritdoc} |
||
109 | */ |
||
110 | protected function getAuthorizationMethod() |
||
114 | |||
115 | /** |
||
116 | * {@inheritdoc} |
||
117 | */ |
||
118 | protected function parseAccessTokenResponse($responseBody) |
||
144 | } |
||
145 |