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

Backend ids like "0012345" are getting forced to int before calls. #125

Open
cottton opened this issue Apr 29, 2022 · 0 comments
Open

Backend ids like "0012345" are getting forced to int before calls. #125

cottton opened this issue Apr 29, 2022 · 0 comments

Comments

@cottton
Copy link

cottton commented Apr 29, 2022

Just happen to me through ticket closing call.

Received ticket with id "00112556780"
But URI gets built with "112556780"

$client = ...
$endpoint = new \Hitmeister\Component\Api\Endpoints\Tickets\Get($client->getTransport());
$endpoint->setId($ticketId);

echo var_export($endpoint->getURI(), true) . PHP_EOL; die;
// tickets/112556780/

Problem:

public function getURI()
{
	if (empty($this->id)) {
		throw new RuntimeException('Required params id is not set');
	}
	return sprintf($this->getUriPattern(), $this->id);
}

protected function getUriPattern()
{
	return 'tickets/%d/';
}

Should have used %s instead of %d.

I guess this will and does happen to all other namespaces too.
I have seen the %d on all sprintf i looked at.


EDIT:

Temp fix: using the transport to perform the request with own uri

GET

$client = ...
$endpoint = new \Hitmeister\Component\Api\Endpoints\Tickets\Get($client->getTransport());
$endpoint->setId($ticketId);
#$result = $endpoint->performRequest(); nope, bugged
$result = $endpoint->getTransport()->performRequest(
    $endpoint->getMethod(),
    sprintf('tickets/%s', $ticketId),
    $endpoint->getParams(),
    $endpoint->getBody(),
    []
);

CLOSE

$client = ...
$endpoint = new \Hitmeister\Component\Api\Endpoints\Tickets\Close($client->getTransport());
$endpoint->setId($ticketId);
#$result = $endpoint->performRequest(); nope, bugged
$result = $endpoint->getTransport()->performRequest(
    $endpoint->getMethod(),
    sprintf('tickets/%s/close/', $ticketId),
    $endpoint->getParams(),
    $endpoint->getBody(),
    []
);
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

No branches or pull requests

1 participant