-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New functionality #3
base: master
Are you sure you want to change the base?
Conversation
(required for resubscribing recipients)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @nkm, thanks for your contribution! This is a great feature. I'm going to leave some comments over the code you wrote. Once you finished, can you squash all your commits into a single commit please?
Unfortunately, this library lacks of tests. I'm also opening an issue to track it down.
Thanks again and sorry for the delay reviewing this!
@@ -19,7 +19,7 @@ | |||
class Context | |||
{ | |||
const AUTH_TOKEN_URI = 'https://services.mailup.com/Authorization/OAuth/Token'; | |||
const BASE_URI = 'https://services.mailup.com/API/v1.1/Rest'; | |||
const BASE_URI = 'https://services.mailup.com/API/v1.1/Rest'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please, do not use internal indentation for assignments
'Content-Type' => 'application/json', | ||
'Authorization' => 'Bearer '.$this->token->getAccessToken(), | ||
], | ||
json_encode($params) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add last ,
$this->username = $options['username']; | ||
$this->password = $options['password']; | ||
$this->username = $options['username']; | ||
$this->password = $options['password']; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please, do not use internal indentation for assignments
$message = "Response not OK when requesting an access token. Response body: $responseBody"; | ||
$responseBody = (string) $response->getBody(); | ||
$message = "Response not OK when requesting an access token. " | ||
. "Response body: {$responseBody}"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do not break a line (event strings) if it stays within the soft limit of PSR-2 (120 chars, http://www.php-fig.org/psr/psr-2/#overview).
Also, keep the operator in the line of the first argument. In this case it should be (but it is not for what mentioned above):
$message = "Response not OK when requesting an access token. " .
"Response body: {$responseBody}"
;
self::AUTH_TOKEN_URI, | ||
[ | ||
'Content-Type' => 'application/x-www-form-urlencoded', | ||
'Authorization' => 'Basic '.base64_encode($this->clientId.':'.$this->clientSecret), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
spaces between .
operator and its arguments
'MobileNumber' => $this->mobileNumber, | ||
'MobilePrefix' => $this->mobilePrefix, | ||
'Fields' => $this->fields, | ||
'Fields' => $this->fields, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
internal indentation
string $refreshToken | ||
) { | ||
$this->accessToken = $accessToken; | ||
$this->validUntil = $validUntilTimestamp; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
internal indentation
if ( | ||
null === $object | ||
|| ! isset($object->accessToken, $object->validUntil, $object->refreshToken) | ||
) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if statement and binary operators
if ( | ||
null === $object | ||
|| ! isset($object->access_token, $object->expires_in, $object->refresh_token) | ||
) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if
and internal indentation
'accessToken' => $this->accessToken, | ||
'validUntil' => $this->validUntil, | ||
'accessToken' => $this->accessToken, | ||
'validUntil' => $this->validUntil, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
internal indentation
@nkm any news about this? |
Hi again,
I've added new functionality to the library:
I've updated the README accordingly.
Finally I've also made some stylistic code changes, mainly to better comply with PSR-2.
Edit: Forgot to add that all changes are Backwards Compatible :)