Skip to content
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

Support for new end points. #10

Merged
merged 6 commits into from
Sep 15, 2014
Merged

Support for new end points. #10

merged 6 commits into from
Sep 15, 2014

Conversation

serargz
Copy link
Contributor

@serargz serargz commented Aug 15, 2014

This pull request contains 3 "big" changes:

  1. Added support for new end points.
  2. Code refactoring.
  3. Tests format change.

Please find below more details.

  1. Authy has exposed the new API end points:
  • Start phone verification (POST /protected/json/phones/verification/start)

  • Check phone verification (GET /protected/json/phones/verification/check)

  • Phone information (GET /protected/json/phones/info)

  • User status (GET /protected/json/users/:user_id/status)

    The phone related methods were encapsulated in the Authy.phone() method. For instance, to call the Start Phone Verification method you need to do:

    authy.phone().verification_start({
      via: "sms",
      country_code: "1",
      phone_number: "111-111-1111"
    }, function(err, res) {
      // Stuff
    } );
  1. A new method (authy._request) was added to handle all the requests (POST and GET) and we use it instead of calling the request object.
  2. In the other hand, the format for the tests added was modified for readability.

New 3 methods: `verification_start`, `verification_check` and `info`
were added to support authy's phone verification and info services.

Usage:

  authy.phones().verification_start({
      via: "sms",
      country_code: "1",
      phone_number: "111-111-1111"
    }
  );

  authy.phones().verification_check({
      country_code: "1",
      phone_number: "111-111-1111",
      verification_code: "0000"
    }
  );

  authy.phones().info({
      country_code: "1",
      phone_number: "111-111-1111"
    }
  );
A new method `_request` was created to handle GET and POST requests.
This allows us to remove repeated code and improve readability.
User status returns the status of a user given the id. A new method
`user_status` along with tests were added to support this end point.
Documentation for the new methods were added:

- start phone verification
- check phone verification
- phone info
- user status
@evilpacket
Copy link
Owner

Given the fact that @jveldridge has been a major contributor in the past and I believe is using this in production I would love their input on this as well.

@evilpacket
Copy link
Owner

Also wanted to say thank you for the PR, I'll try and review as soon as I can. :)

user_status(id, callback);

```javascript
authy.user_satus('1337', function (err, res) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/satus/status

@jveldridge
Copy link
Contributor

I don't see the new endpoints documented at docs.authy.com--do you know if they will be added there?

@serargz
Copy link
Contributor Author

serargz commented Aug 15, 2014

@jveldridge they are. There is a menu ("Jump to...") in the top right corner. We should make it more visible though.

});
};

switch(type) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should an if statement instead of a switch, there are only 2 cases

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or just add the method correct method to the options for the request module and forego the flow control statements completely

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, that was thinking in possible changes in the future, like adding other methods (put, delete).

Phone verification methods were modified to accept individual parameters
instead of an options object.
@serargz
Copy link
Contributor Author

serargz commented Aug 15, 2014

I've pushed a new commit. I decided to remove the options parameter and add the parameters for each method, as their will be static and it's not likely they change in the future.

@serargz
Copy link
Contributor Author

serargz commented Sep 5, 2014

Hi @evilpacket, do you have plans to merge this PR?

@dacbd
Copy link
Collaborator

dacbd commented Sep 5, 2014

He is out ATM, I can talk to him on monday, if he hasn't merged/published it over the weekend

@evilpacket
Copy link
Owner

Sorry for the delay. If Daniel has merge button permission he can do so otherwise I'll do so after I'm not crazy busy. Hopefully this weekend.

On Sep 5, 2014, at 1:10 PM, Sergio [email protected] wrote:

Hi @evilpacket, do you have plans to merge this PR?


Reply to this email directly or view it on GitHub.

evilpacket pushed a commit that referenced this pull request Sep 15, 2014
Support for new end points.
@evilpacket evilpacket merged commit 6e7e1f8 into evilpacket:master Sep 15, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants