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

chore: add required query param in read operations php #631

Merged
merged 2 commits into from
Jan 16, 2025

Conversation

tiwarishubham635
Copy link
Contributor

@tiwarishubham635 tiwarishubham635 commented Jan 13, 2025

Fixes #DI-1676

Add required query params in read operation for PHP.
Verified that this issue is only in PHP and not in any other language.
Review PR for php: twilio/twilio-php#842 [Do not merge]

Checklist

  • I acknowledge that all my contributions will be made under the project's license
  • Run make test-docker
  • Verify affected language:
    • Generate twilio-php from our OpenAPI specification using the build_twilio_go.py using python examples/build_twilio_go.py path/to/twilio-oai/spec/yaml path/to/twilio-go and inspect the diff
    • Run make test in twilio-php
    • Create a pull request in twilio-php
    • Provide a link below to the pull request
  • I have made a material change to the repo (functionality, testing, spelling, grammar)
  • I have read the Contribution Guidelines and my PR follows them
  • I have titled the PR appropriately
  • I have updated my branch with the main branch
  • I have added tests that prove my fix is effective or that my feature works
  • I have added the necessary documentation about the functionality in the appropriate .md file
  • I have added inline documentation to the code I modified

If you have questions, please create a GitHub Issue in this repository.

@tiwarishubham635
Copy link
Contributor Author

PHP preview PR - twilio/twilio-php#842

@@ -89,6 +89,24 @@
{{/vendorExtensions.x-serialize-map}}
{{/vendorExtensions.x-serialize}}
{{/vendorExtensions.optionFileParams}}
{{#queryParams.0}}
Copy link
Contributor

Choose a reason for hiding this comment

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

verify with multiple required query parameters.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay

Copy link

Copy link

Copy link

Copy link

@tiwarishubham635
Copy link
Contributor Author

Verified the following cases of objects and maps. In PHP, Object implies dataTypes like date and bool. While all lists and maps are treated as array.

Example spec:

{
  "name": "AccountSid",
  "in": "query",
  "description": "The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Payments resource.",
  "schema": {
    "type": "string",
    "minLength": 34,
    "maxLength": 34,
    "pattern": "^AC[0-9a-fA-F]{32}$"
  },
  "required": true,
  "examples": {
    "readEmpty": {
      "value": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
    },
    "readFull": {
      "value": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
    }
  }
},
{
  "name": "MessageDate",
  "in": "query",
  "description": "Only show notifications for the specified date, formatted as `YYYY-MM-DD`. You can also specify an inequality, such as `<=YYYY-MM-DD` for messages logged at or before midnight on a date, or `>=YYYY-MM-DD` for messages logged at or after midnight on a date.",
  "schema": {
    "type": "string",
    "format": "date"
  },
  "examples": {
    "readFull": {
      "value": "2008-01-02"
    },
    "readEmpty": {
      "value": "2008-01-02"
    }
  }
},
{
  "name": "ListOfNames",
  "in": "query",
  "description": "A comma-separated list of the names of the keys to retrieve.",
  "schema": {
    "type": "array",
      "items": {
          "type": "string"
      }
  },
  "examples": {
    "readFull": {
      "value": ["foo", "bar"]
    },
    "readEmpty": {
      "value": ["foo", "bar"]
    }
  }
},

Generated code in PHP:

'MessageDate' =>
    Serialize::iso8601Date($options['messageDate']),
'ListOfNames' =>
    Serialize::map($options['listOfNames'], function ($e) { return $e; }),
'AccountSid' =>
    $options['accountSid'],

@tiwarishubham635 tiwarishubham635 merged commit 468062a into main Jan 16, 2025
17 of 21 checks passed
@tiwarishubham635 tiwarishubham635 deleted the required_query_params_php branch January 16, 2025 07:46
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.

2 participants