Problem with version change

Issue #47 wontfix
Rodrigo Lacerda created an issue

There is a problem when you run a method that uses version 2 and then run a method that uses 1.0 version. In this case when it is running version 1.0 of the method it will continue with the endpoints of version 2.0.

To test:

$ Repo = new \bitbucket\API\Repositories\Repository();
$ Repo->setCredentials (new  \bitbucket\API\Authentication\Basic($user, $pass));
$ Repository = $repo->get($user, $slug); // Will user V2.0
$ Branchs = $repo->branches($user, $slug); // Will use v 1.0 with endpoint v 2.0. Error!

I know it's none of my business ... but I think the ideal would be to have an interface with all the methods used in v1 and v2. And create separate classes for v1 and v2 implementanto the interface.

Comments (1)

  1. Alexandru Guzinschi

    Because there are similar endpoints for v1 and v2 of the API (which work in parallel at this time), we can't enforce an API version for each method. The only place where we can do this are a handful of methods which cover a few endpoints from v2 of the API which are unique (i.e: there is no similar endpoint in v1 of the API).

    Each user can (and should) change the API version according to his/her needs with getClient()->setApiVersion() method:

    $repo->getClient()->setApiVersion('1.0');
    $branches = $repo->branches($user, $slug);
    
  2. Log in to comment