Skip to content

Commit f9ce354

Browse files
authored
Merge branch 'main' into generate-script
2 parents 972ed09 + 5994fe0 commit f9ce354

File tree

17 files changed

+49
-32
lines changed

17 files changed

+49
-32
lines changed

examples/php/src/Twilio/Rest/Api/V2010/Account/Call/FeedbackCallSummaryContext.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public function update(\DateTime $endDate, \DateTime $startDate, array $options
8282
$options['accountSid'],
8383
]);
8484

85-
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded' ]);
85+
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
8686
$payload = $this->version->update('POST', $this->uri, [], $data, $headers);
8787

8888
return new FeedbackCallSummaryInstance(

examples/php/src/Twilio/Rest/Api/V2010/Account/CallContext.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public function delete(): bool
8686
public function fetch(): CallInstance
8787
{
8888

89-
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded' ]);
89+
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
9090
$payload = $this->version->fetch('GET', $this->uri, [], [], $headers);
9191

9292
return new CallInstance(

examples/php/src/Twilio/Rest/Api/V2010/Account/CallList.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public function create(string $requiredStringProperty, string $testMethod, array
8585
Serialize::map($options['testArrayOfUri'], function ($e) { return $e; }),
8686
]);
8787

88-
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded' ]);
88+
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
8989
$payload = $this->version->create('POST', $this->uri, [], $data, $headers);
9090

9191
return new CallInstance(

examples/php/src/Twilio/Rest/Api/V2010/AccountContext.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public function delete(): bool
8484
public function fetch(): AccountInstance
8585
{
8686

87-
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded' ]);
87+
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
8888
$payload = $this->version->fetch('GET', $this->uri, [], [], $headers);
8989

9090
return new AccountInstance(
@@ -115,7 +115,7 @@ public function update(string $status, array $options = []): AccountInstance
115115
$options['pauseBehavior'],
116116
]);
117117

118-
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded' ]);
118+
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
119119
$payload = $this->version->update('POST', $this->uri, [], $data, $headers);
120120

121121
return new AccountInstance(

examples/php/src/Twilio/Rest/Api/V2010/AccountList.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public function create(array $options = []): AccountInstance
7070
$options['twiml'],
7171
]);
7272

73-
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded' , 'X-Twilio-Webhook-Enabled' => $options['xTwilioWebhookEnabled']]);
73+
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' , 'X-Twilio-Webhook-Enabled' => $options['xTwilioWebhookEnabled']]);
7474
$payload = $this->version->create('POST', $this->uri, [], $data, $headers);
7575

7676
return new AccountInstance(
@@ -161,7 +161,8 @@ public function page(
161161
'PageSize' => $pageSize,
162162
]);
163163

164-
$response = $this->version->page('GET', $this->uri, $params);
164+
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json']);
165+
$response = $this->version->page('GET', $this->uri, $params, [], $headers);
165166

166167
return new AccountPage($this->version, $response, $this->solution);
167168
}

examples/php/src/Twilio/Rest/FlexApi/V1/CallContext.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public function __construct(
6363
public function update(): CallInstance
6464
{
6565

66-
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded' ]);
66+
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
6767
$payload = $this->version->update('POST', $this->uri, [], [], $headers);
6868

6969
return new CallInstance(

examples/php/src/Twilio/Rest/FlexApi/V1/Credential/Aws/HistoryContext.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public function fetch(array $options = []): HistoryInstance
7070
]);
7171
$params = \array_merge($params, Serialize::prefixedCollapsibleMap($options['addOnsData'], 'AddOns'));
7272

73-
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded' ]);
73+
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
7474
$payload = $this->version->fetch('GET', $this->uri, $params, [], $headers);
7575

7676
return new HistoryInstance(

examples/php/src/Twilio/Rest/FlexApi/V1/Credential/AwsContext.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public function delete(): bool
8484
public function fetch(): AwsInstance
8585
{
8686

87-
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded' ]);
87+
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
8888
$payload = $this->version->fetch('GET', $this->uri, [], [], $headers);
8989

9090
return new AwsInstance(
@@ -114,7 +114,7 @@ public function update(array $options = []): AwsInstance
114114
Serialize::booleanToString($options['testBoolean']),
115115
]);
116116

117-
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded' ]);
117+
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
118118
$payload = $this->version->update('POST', $this->uri, [], $data, $headers);
119119

120120
return new AwsInstance(

examples/php/src/Twilio/Rest/FlexApi/V1/Credential/AwsList.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,8 @@ public function page(
118118
'PageSize' => $pageSize,
119119
]);
120120

121-
$response = $this->version->page('GET', $this->uri, $params);
121+
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json']);
122+
$response = $this->version->page('GET', $this->uri, $params, [], $headers);
122123

123124
return new AwsPage($this->version, $response, $this->solution);
124125
}

examples/php/src/Twilio/Rest/FlexApi/V1/Credential/NewCredentialsList.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public function create(string $testString, array $options = []): NewCredentialsI
9898
$options['someA2PThing'],
9999
]);
100100

101-
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded' ]);
101+
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
102102
$payload = $this->version->create('POST', $this->uri, [], $data, $headers);
103103

104104
return new NewCredentialsInstance(

examples/php/src/Twilio/Rest/Versionless/DeployedDevices/FleetContext.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public function __construct(
6363
public function fetch(): FleetInstance
6464
{
6565

66-
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded' ]);
66+
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
6767
$payload = $this->version->fetch('GET', $this->uri, [], [], $headers);
6868

6969
return new FleetInstance(

examples/php/src/Twilio/Rest/Versionless/DeployedDevices/FleetList.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public function create(array $options = []): FleetInstance
6565
$options['name'],
6666
]);
6767

68-
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded' ]);
68+
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
6969
$payload = $this->version->create('POST', $this->uri, [], $data, $headers);
7070

7171
return new FleetInstance(

examples/php/src/Twilio/Rest/Versionless/Understand/AssistantList.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,8 @@ public function page(
117117
'PageSize' => $pageSize,
118118
]);
119119

120-
$response = $this->version->page('GET', $this->uri, $params);
120+
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json']);
121+
$response = $this->version->page('GET', $this->uri, $params, [], $headers);
121122

122123
return new AssistantPage($this->version, $response, $this->solution);
123124
}

scripts/build_twilio_library.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
generateForLanguages = {
2525
'twilio_iam_organizations.json' : ['java', 'csharp']
2626
}
27-
dynamic_languages = ['node', 'python', 'ruby']
27+
dynamic_languages = ['node', 'python', 'ruby', 'php']
2828
CLEANUP_IMPORT_LANGUAGES = ['java', 'php']
2929
REMOVE_DUPLICATE_IMPORT_LANGUAGES = ['node']
3030
CONFIG_FOLDER = 'tmp'

src/main/java/com/twilio/oai/api/PhpApiResourceBuilder.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,16 @@ private void updateNamespaceSubPart(CodegenOperation codegenOperation) {
161161
namespaceSubPart = namespaceSubPart.replaceAll("\\\\Function[\\\\]", "\\\\TwilioFunction\\\\");
162162
}
163163

164+
private List<CodegenParameter> filterPagingParams(List<CodegenParameter> queryParams) {
165+
List<CodegenParameter> nonPagingParams = new ArrayList<>();
166+
for (CodegenParameter param : queryParams) {
167+
if (!param.baseName.startsWith("Page")) {
168+
nonPagingParams.add(param);
169+
}
170+
}
171+
return nonPagingParams;
172+
}
173+
164174
@Override
165175
public ApiResourceBuilder updateOperations(Resolver<CodegenParameter> codegenParameterIResolver) {
166176
PhpJsonRequestBodyResolver jsonRequestBodyResolver = new PhpJsonRequestBodyResolver(this, codegenPropertyIResolver);
@@ -185,6 +195,10 @@ public ApiResourceBuilder updateOperations(Resolver<CodegenParameter> codegenPar
185195
co.queryParams = co.queryParams.stream()
186196
.map(item -> codegenParameterIResolver.resolve(item, this))
187197
.collect(Collectors.toList());
198+
List<CodegenParameter> nonPagingParams = filterPagingParams(co.queryParams);
199+
if (!nonPagingParams.isEmpty()) {
200+
co.vendorExtensions.put("x-has-non-pagination-params", true);
201+
}
188202
co.formParams = co.formParams.stream()
189203
.map(item -> codegenParameterIResolver.resolve(item, this))
190204
.collect(Collectors.toList());

src/main/resources/twilio-php/contextMethod.mustache

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,11 +132,10 @@
132132
{{/optionalParams}}
133133

134134
{{/formParams.0}}
135-
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded' {{#headerParams}}{{#required}}, '{{baseName}}' =>
135+
$headers = Values::of([{{^consumes}}'Content-Type' => 'application/x-www-form-urlencoded'{{/consumes}}{{#consumes}}{{#-first}}'Content-Type' => '{{{mediaType}}}'{{/-first}}{{/consumes}}{{^vendorExtensions.x-is-delete-operation}}{{#produces}}{{#-first}}, 'Accept' => '{{{mediaType}}}'{{/-first}}{{/produces}}{{/vendorExtensions.x-is-delete-operation}} {{#headerParams}}{{#required}}, '{{baseName}}' =>
136136
${{#lambda.camelcase}}{{baseName}}{{/lambda.camelcase}}{{/required}}{{/headerParams}}{{#headerParams}}{{^required}}, '{{baseName}}' => $options['{{#lambda.camelcase}}{{baseName}}{{/lambda.camelcase}}']{{/required}}{{/headerParams}}]);
137137
{{#bodyParams.0}}
138138
$data = ${{#lambda.camelcase}}{{baseName}}{{/lambda.camelcase}}->toArray();
139-
$headers['Content-Type'] = 'application/json';
140139
{{/bodyParams.0}}
141140
{{^vendorExtensions.x-is-delete-operation}}
142141
$payload = $this->version->{{#lambda.camelcase}}{{vendorExtensions.x-name}}{{/lambda.camelcase}}('{{httpMethod}}', $this->uri{{#queryParams.0}}, $params{{/queryParams.0}}{{^queryParams}}, []{{/queryParams}}{{#formParams.0}}, $data{{/formParams.0}}{{^formParams}}{{#bodyParams.0}}, $data{{/bodyParams.0}}{{^bodyParams}}, []{{/bodyParams}}{{/formParams}}, $headers);

src/main/resources/twilio-php/listRead.mustache

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
* Unlike stream(), this operation is eager and will load `limit` records into
55
* memory before returning.
66
*
7-
{{#queryParams.1}}
7+
{{#vendorExtensions.x-has-non-pagination-params}}
88
* @param array|Options $options Optional Arguments
9-
{{/queryParams.1}}
9+
{{/vendorExtensions.x-has-non-pagination-params}}
1010
* @param int $limit Upper limit for the number of records to return. read()
1111
* guarantees to never return more than limit. Default is no
1212
* limit
@@ -17,9 +17,9 @@
1717
* efficient page size, i.e. min(limit, 1000)
1818
* @return {{apiName}}Instance[] Array of results
1919
*/
20-
public function read({{#queryParams.1}}array $options = [], {{/queryParams.1}}int $limit = null, $pageSize = null): array
20+
public function read({{#vendorExtensions.x-has-non-pagination-params}}array $options = [], {{/vendorExtensions.x-has-non-pagination-params}}int $limit = null, $pageSize = null): array
2121
{
22-
return \iterator_to_array($this->stream({{#queryParams.1}}$options, {{/queryParams.1}}$limit, $pageSize), false);
22+
return \iterator_to_array($this->stream({{#vendorExtensions.x-has-non-pagination-params}}$options, {{/vendorExtensions.x-has-non-pagination-params}}$limit, $pageSize), false);
2323
}
2424

2525
/**
@@ -30,9 +30,9 @@
3030
* The results are returned as a generator, so this operation is memory
3131
* efficient.
3232
*
33-
{{#queryParams.1}}
33+
{{#vendorExtensions.x-has-non-pagination-params}}
3434
* @param array|Options $options Optional Arguments
35-
{{/queryParams.1}}
35+
{{/vendorExtensions.x-has-non-pagination-params}}
3636
* @param int $limit Upper limit for the number of records to return. stream()
3737
* guarantees to never return more than limit. Default is no
3838
* limit
@@ -43,11 +43,11 @@
4343
* efficient page size, i.e. min(limit, 1000)
4444
* @return Stream stream of results
4545
*/
46-
public function stream({{#queryParams.1}}array $options = [], {{/queryParams.1}}int $limit = null, $pageSize = null): Stream
46+
public function stream({{#vendorExtensions.x-has-non-pagination-params}}array $options = [], {{/vendorExtensions.x-has-non-pagination-params}}int $limit = null, $pageSize = null): Stream
4747
{
4848
$limits = $this->version->readLimits($limit, $pageSize);
4949
50-
$page = $this->page({{#queryParams.1}}$options, {{/queryParams.1}}$limits['pageSize']);
50+
$page = $this->page({{#vendorExtensions.x-has-non-pagination-params}}$options, {{/vendorExtensions.x-has-non-pagination-params}}$limits['pageSize']);
5151

5252
return $this->version->stream($page, $limits['limit'], $limits['pageLimit']);
5353
}
@@ -62,15 +62,15 @@
6262
* @return {{apiName}}Page Page of {{apiName}}Instance
6363
*/
6464
public function page(
65-
{{#queryParams.1}}array $options = [],
66-
{{/queryParams.1}}$pageSize = Values::NONE,
65+
{{#vendorExtensions.x-has-non-pagination-params}}array $options = [],
66+
{{/vendorExtensions.x-has-non-pagination-params}}$pageSize = Values::NONE,
6767
string $pageToken = Values::NONE,
6868
$pageNumber = Values::NONE
6969
): {{apiName}}Page
7070
{
71-
{{#queryParams.1}}
71+
{{#vendorExtensions.x-has-non-pagination-params}}
7272
$options = new Values($options);
73-
{{/queryParams.1}}
73+
{{/vendorExtensions.x-has-non-pagination-params}}
7474

7575
$params = Values::of([
7676
{{#vendorExtensions.optionFileParams}}
@@ -112,7 +112,8 @@
112112
'PageSize' => $pageSize,
113113
]);
114114

115-
$response = $this->version->page('{{httpMethod}}', $this->uri, $params);
115+
$headers = Values::of([{{^consumes}}'Content-Type' => 'application/x-www-form-urlencoded'{{/consumes}}{{#consumes}}{{#-first}}'Content-Type' => '{{{mediaType}}}'{{/-first}}{{/consumes}}{{#produces}}{{#-first}}, 'Accept' => '{{{mediaType}}}'{{/-first}}{{/produces}}]);
116+
$response = $this->version->page('{{httpMethod}}', $this->uri, $params, [], $headers);
116117

117118
return new {{apiName}}Page($this->version, $response, $this->solution);
118119
}

0 commit comments

Comments
 (0)