Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix(php): Fix date formatting in ObjectSerializer#372

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
UNIT23 wants to merge1 commit intoapivideo:main
base:main
Choose a base branch
Loading
fromUNIT23:bugfix/fix-object-serializer-sanitize-date

Conversation

@UNIT23
Copy link

Problem :
FunctiongetVideosPlays() from Analytics PHP Api throw 400 error :
ApiVideo\Client\Exception\HttpException: HTTP 400 returned. {"type":"https:\/\/docs.api.video\/reference\/request-invalid-query-parameter","title":"A query parameter is invalid.","status":400,"detail":"This value is not a valid date.","name":"from"}

Code :
$dateFrom = (new DateTime())->sub(new DateInterval('P1D')); $apiVideoSessions = $this->client->analytics()->getVideosPlays($dateFrom, 'videoId');

Because :
In src/Api/AnalyticsApi.php :

  • line 103 :$queryParams['from'] = ObjectSerializer::sanitizeForSerialization($from, 'date');
  • line 104 :$queryParams['to'] = ObjectSerializer::sanitizeForSerialization($to, 'date');
  • line 209 :$queryParams['from'] = ObjectSerializer::sanitizeForSerialization($from, 'date');
  • line 214 :$queryParams['to'] = ObjectSerializer::sanitizeForSerialization($to, 'date');

Second parameter of ObjectSerializer::sanitizeForSerialization must be $type and not $format.

InObjectSerializer::sanitizeForSerialization($data, $type = null, $format = null) :
if ($data instanceof \DateTime) { return ($format === 'date') ? $data->format('Y-m-d') : $data->format(self::$dateTimeFormat); }

Fix :
if ($data instanceof \DateTime) { return ($type === 'date' || $format === 'date') ? $data->format('Y-m-d') : $data->format(self::$dateTimeFormat); }

@UNIT23UNIT23 marked this pull request as draftApril 5, 2024 12:27
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

1 participant

@UNIT23

[8]ページ先頭

©2009-2025 Movatter.jp