Skip to content

Commit

Permalink
Deprecation: avoid passing json encoded strings to post|put calls
Browse files Browse the repository at this point in the history
  • Loading branch information
glaubinix committed Nov 15, 2023
1 parent f7d9fef commit 60c74c9
Show file tree
Hide file tree
Showing 10 changed files with 19 additions and 25 deletions.
4 changes: 2 additions & 2 deletions lib/Bitbucket/API/Repositories/BranchRestrictions.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public function create($account, $repo, $params = array())

return $this->getClient()->setApiVersion('2.0')->post(
sprintf('/repositories/%s/%s/branch-restrictions', $account, $repo),
json_encode($params),
$params,
array('Content-Type' => 'application/json')
);
}
Expand Down Expand Up @@ -135,7 +135,7 @@ public function update($account, $repo, $id, $params = array())

return $this->getClient()->setApiVersion('2.0')->put(
sprintf('/repositories/%s/%s/branch-restrictions/%d', $account, $repo, $id),
json_encode($params),
$params,
array('Content-Type' => 'application/json')
);
}
Expand Down
4 changes: 2 additions & 2 deletions lib/Bitbucket/API/Repositories/Commits/BuildStatuses.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function create($account, $repository, $revision, $params)
{
return $this->getClient()->setApiVersion('2.0')->post(
sprintf('/repositories/%s/%s/commit/%s/statuses/build', $account, $repository, $revision),
json_encode($params),
$params,
array('Content-Type' => 'application/json')
);
}
Expand All @@ -74,7 +74,7 @@ public function update($account, $repository, $revision, $key, $params)
{
return $this->getClient()->setApiVersion('2.0')->put(
sprintf('/repositories/%s/%s/commit/%s/statuses/build/%s', $account, $repository, $revision, $key),
json_encode($params),
$params,
array('Content-Type' => 'application/json')
);
}
Expand Down
4 changes: 2 additions & 2 deletions lib/Bitbucket/API/Repositories/Hooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function create($account, $repo, array $params = array())

return $this->getClient()->setApiVersion('2.0')->post(
sprintf('/repositories/%s/%s/hooks', $account, $repo),
json_encode($params),
$params,
array('Content-Type' => 'application/json')
);
}
Expand Down Expand Up @@ -83,7 +83,7 @@ public function update($account, $repo, $uuid, array $params = array())

return $this->getClient()->setApiVersion('2.0')->put(
sprintf('/repositories/%s/%s/hooks/%s', $account, $repo, $uuid),
json_encode($params),
$params,
array('Content-Type' => 'application/json')
);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Bitbucket/API/Repositories/Pipelines.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function create($account, $repo, $params = array())

return $this->getClient()->setApiVersion('2.0')->post(
sprintf('/repositories/%s/%s/pipelines/', $account, $repo),
json_encode($params),
$params,
array('Content-Type' => 'application/json')
);
}
Expand Down
8 changes: 4 additions & 4 deletions lib/Bitbucket/API/Repositories/PullRequests.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public function create($account, $repo, $params = array())

return $this->getClient()->setApiVersion('2.0')->post(
sprintf('/repositories/%s/%s/pullrequests', $account, $repo),
json_encode($params),
$params,
array('Content-Type' => 'application/json')
);
}
Expand Down Expand Up @@ -168,7 +168,7 @@ public function update($account, $repo, $id, $params = array())

return $this->getClient()->setApiVersion('2.0')->put(
sprintf('/repositories/%s/%s/pullrequests/%d', $account, $repo, $id),
json_encode($params),
$params,
array('Content-Type' => 'application/json')
);
}
Expand Down Expand Up @@ -302,7 +302,7 @@ public function accept($account, $repo, $id, $params = array())
{
return $this->getClient()->setApiVersion('2.0')->post(
sprintf('/repositories/%s/%s/pullrequests/%d/merge', $account, $repo, $id),
json_encode($params),
$params,
array('Content-Type' => 'application/json')
);
}
Expand All @@ -324,7 +324,7 @@ public function decline($account, $repo, $id, $params = array())

return $this->getClient()->setApiVersion('2.0')->post(
sprintf('/repositories/%s/%s/pullrequests/%d/decline', $account, $repo, $id),
json_encode($params),
$params,
array('Content-Type' => 'application/json')
);
}
Expand Down
4 changes: 2 additions & 2 deletions lib/Bitbucket/API/Repositories/PullRequests/Comments.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public function create($account, $repo, $requestID, $content)
{
return $this->getClient()->setApiVersion('2.0')->post(
sprintf('/repositories/%s/%s/pullrequests/%d/comments', $account, $repo, $requestID),
json_encode(array('content' => array('raw' => $content))),
array('content' => array('raw' => $content)),
array('Content-Type' => 'application/json')
);
}
Expand All @@ -84,7 +84,7 @@ public function update($account, $repo, $requestID, $commentID, $content)
{
return $this->getClient()->setApiVersion('2.0')->put(
sprintf('/repositories/%s/%s/pullrequests/%d/comments/%d', $account, $repo, $requestID, $commentID),
json_encode(array('content' => array('raw' => $content))),
array('content' => array('raw' => $content)),
array('Content-Type' => 'application/json')
);
}
Expand Down
4 changes: 1 addition & 3 deletions lib/Bitbucket/API/Repositories/Refs/Tags.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,9 @@ public function create($account, $repo, $name, $hash)
],
];

$data = json_encode($params);

return $this->getClient()->setApiVersion('2.0')->post(
sprintf('/repositories/%s/%s/refs/tags', $account, $repo),
$data,
$params,
array('Content-Type' => 'application/json')
);
}
Expand Down
6 changes: 1 addition & 5 deletions lib/Bitbucket/API/Repositories/Repository.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,9 @@ public function create($account, $repo, $params = array())
$params = $this->decodeJSON($params);
}

$params = json_encode(array_merge($defaults, $params));

return $this->getClient()->setApiVersion('2.0')->post(
sprintf('/repositories/%s/%s', $account, $repo),
$params,
array_merge($defaults, $params),
array('Content-Type' => 'application/json')
);
}
Expand Down Expand Up @@ -155,8 +153,6 @@ public function fork($account, $repo, $name, array $params = array())
{
$params['name'] = $name;

$params = json_encode($params);

return $this->getClient()->setApiVersion('2.0')->post(
sprintf('/repositories/%s/%s/forks', $account, $repo),
$params,
Expand Down
4 changes: 2 additions & 2 deletions lib/Bitbucket/API/Teams/Hooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function create($team, array $hookConfiguration)

return $this->getClient()->setApiVersion('2.0')->post(
sprintf('/teams/%s/hooks', $team),
json_encode($hookConfiguration),
$hookConfiguration,
['Content-Type' => 'application/json']
);
}
Expand Down Expand Up @@ -65,7 +65,7 @@ public function update($team, $uuid, array $hookConfiguration)

return $this->getClient()->setApiVersion('2.0')->put(
sprintf('/teams/%s/hooks/%s', $team, $uuid),
json_encode($hookConfiguration),
$hookConfiguration,
['Content-Type' => 'application/json']
);
}
Expand Down
4 changes: 2 additions & 2 deletions lib/Bitbucket/API/Workspaces/Hooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function create($workspace, array $hookConfiguration)

return $this->getClient()->setApiVersion('2.0')->post(
sprintf('/workspaces/%s/hooks', $workspace),
json_encode($hookConfiguration),
$hookConfiguration,
['Content-Type' => 'application/json']
);
}
Expand Down Expand Up @@ -65,7 +65,7 @@ public function update($workspace, $uuid, array $hookConfiguration)

return $this->getClient()->setApiVersion('2.0')->put(
sprintf('/workspaces/%s/hooks/%s', $workspace, $uuid),
json_encode($hookConfiguration),
$hookConfiguration,
['Content-Type' => 'application/json']
);
}
Expand Down

0 comments on commit 60c74c9

Please sign in to comment.