Skip to content

Commit c0f638e

Browse files
authored
chore: add context template (#346)
<!-- We appreciate the effort for this pull request but before that please make sure you read the contribution guidelines, then fill out the blanks below. Please format the PR title appropriately based on the type of change: <type>[!]: <description> Where <type> is one of: docs, chore, feat, fix, test, misc. Add a '!' after the type for breaking changes (e.g. feat!: new breaking feature). **All third-party contributors acknowledge that any contributions they provide will be made under the same open-source license that the open-source project is provided under.** Please enter each Issue number you are resolving in your PR after one of the following words [Fixes, Closes, Resolves]. This will auto-link these issues and close them when this PR is merged! e.g. Fixes #1 Closes #2 --> # Fixes # - set context template - set list Constructor params - add @Property and @method annotations to context and list files - set correct arguments for CRUD function calls ### Checklist - [x] I acknowledge that all my contributions will be made under the project's license - [ ] Run `make test-docker` - [ ] Verify affected language: - [ ] Generate [twilio-go](https://github.com/twilio/twilio-go) from our [OpenAPI specification](https://github.com/twilio/twilio-oai) using the [build_twilio_go.py](./examples/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-go` - [ ] Create a pull request in `twilio-go` - [ ] 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](https://github.com/twilio/twilio-oai-generator/blob/main/CONTRIBUTING.md) 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.
1 parent e512b10 commit c0f638e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+1273
-212
lines changed

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

Lines changed: 57 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,71 @@
1515
*/
1616

1717

18-
namespace Twilio\Rest\Api\V2010;
18+
namespace Twilio\Rest\Api\V2010\Account\Call;
1919

2020
use Twilio\Exceptions\TwilioException;
2121
use Twilio\ListResource;
2222
use Twilio\Options;
2323
use Twilio\Stream;
2424
use Twilio\Values;
2525
use Twilio\Version;
26+
use Twilio\InstanceContext;
27+
use Twilio\Deserialize;
28+
use Twilio\Serialize;
2629

27-
/**
28-
*/
29-
class Context extends InstanceContext {
3030

3131

32-
}
32+
class FeedbackCallSummaryContext extends InstanceContext {
33+
34+
/**
35+
* Initialize the FeedbackCallSummaryContext
36+
*
37+
* @param Version $version Version that contains the resource
38+
* @param string $accountSid
39+
* @param string $sid
40+
*/
41+
public function __construct(Version $version, $accountSid , $sid ) {
42+
parent::__construct($version);
43+
44+
// Path Solution
45+
$this->solution = ['account_sid' => $accountSid, 'sid' => $sid, ];
46+
47+
$this->uri = '/Accounts/' . \rawurlencode($accountSid) . '/Calls/Feedback/Summary/' . \rawurlencode($sid) . '.json';
48+
}
49+
50+
/**
51+
* Update the FeedbackCallSummaryInstance
52+
*
53+
* @param \DateTime $endDate
54+
* @param \DateTime $startDate
55+
* @param array|Options $options Optional Arguments
56+
* @return FeedbackCallSummaryInstance Updated FeedbackCallSummaryInstance
57+
* @throws TwilioException When an HTTP error occurs.
58+
*/
59+
public function update(\DateTime $endDate, \DateTime $startDate, array $options = []): FeedbackCallSummaryInstance {
60+
$options = new Values($options);
3361

62+
$data = Values::of([
63+
'EndDate' => Serialize::iso8601Date($endDate),
64+
'StartDate' => Serialize::iso8601Date($startDate),
65+
'AccountSid' => $options['accountSid'],
66+
]);
67+
68+
$payload = $this->version->update('POST', $this->uri, [], $data);
69+
70+
return new FeedbackCallSummaryInstance($this->version, $payload, $this->solution['accountSid'], $this->solution['sid']);
71+
}
72+
73+
/**
74+
* Provide a friendly representation
75+
*
76+
* @return string Machine friendly representation
77+
*/
78+
public function __toString(): string {
79+
$context = [];
80+
foreach ($this->solution as $key => $value) {
81+
$context[] = "$key=$value";
82+
}
83+
return '[Twilio.Api.V2010.FeedbackCallSummaryContext ' . \implode(' ', $context) . ']';
84+
}
85+
}

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323
use Twilio\Stream;
2424
use Twilio\Values;
2525
use Twilio\Version;
26+
use Twilio\InstanceContext;
27+
use Twilio\Deserialize;
28+
use Twilio\Serialize;
2629

2730

2831
/**

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

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,27 +14,31 @@
1414
* Do not edit the class manually.
1515
*/
1616

17-
namespace Twilio\Rest\Api\V2010;
17+
namespace Twilio\Rest\Api\V2010\Account\Call;
1818

1919
use Twilio\Exceptions\TwilioException;
2020
use Twilio\ListResource;
2121
use Twilio\Options;
2222
use Twilio\Stream;
2323
use Twilio\Values;
2424
use Twilio\Version;
25+
use Twilio\InstanceContext;
26+
use Twilio\Deserialize;
27+
use Twilio\Serialize;
28+
2529

2630

2731
class FeedbackCallSummaryList extends ListResource {
2832
/**
2933
* Construct the FeedbackCallSummaryList
3034
*
3135
* @param Version $version Version that contains the resource
32-
* @param string $accountSid
33-
* @param string $sid
3436
*/
35-
public function __construct(Version $version, string $accountSid , string $sid ) {
37+
public function __construct(Version $version) {
3638
parent::__construct($version);
37-
$this->solution = ['account_sid' => $accountSid, 'sid' => $sid ];
39+
40+
// Path Solution
41+
$this->solution = [];
3842
}
3943

4044

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323
use Twilio\Stream;
2424
use Twilio\Values;
2525
use Twilio\Version;
26+
use Twilio\InstanceContext;
27+
use Twilio\Deserialize;
28+
use Twilio\Serialize;
2629

2730

2831
abstract class FeedbackCallSummaryOptions {

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

Lines changed: 57 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,71 @@
1515
*/
1616

1717

18-
namespace Twilio\Rest\Api\V2010;
18+
namespace Twilio\Rest\Api\V2010\Account;
1919

2020
use Twilio\Exceptions\TwilioException;
2121
use Twilio\ListResource;
2222
use Twilio\Options;
2323
use Twilio\Stream;
2424
use Twilio\Values;
2525
use Twilio\Version;
26+
use Twilio\InstanceContext;
27+
use Twilio\Deserialize;
28+
use Twilio\Serialize;
2629

27-
/**
28-
*/
29-
class Context extends InstanceContext {
3030

3131

32-
}
32+
class CallContext extends InstanceContext {
33+
34+
/**
35+
* Initialize the CallContext
36+
*
37+
* @param Version $version Version that contains the resource
38+
* @param string $accountSid
39+
* @param int $testInteger INTEGER ID param!!!
40+
*/
41+
public function __construct(Version $version, $accountSid , $testInteger ) {
42+
parent::__construct($version);
43+
44+
// Path Solution
45+
$this->solution = ['account_sid' => $accountSid, 'test_integer' => $testInteger, ];
46+
47+
$this->uri = '/Accounts/' . \rawurlencode($accountSid) . '/Calls/' . \rawurlencode($testInteger) . '.json';
48+
}
49+
50+
/**
51+
* Delete the CallInstance
52+
*
53+
* @return bool True if delete succeeds, false otherwise
54+
* @throws TwilioException When an HTTP error occurs.
55+
*/
56+
public function delete(): bool {
57+
return $this->version->delete('DELETE', $this->uri);
58+
}
3359

60+
/**
61+
* Fetch the CallInstance
62+
*
63+
* @return CallInstance Fetched CallInstance
64+
* @throws TwilioException When an HTTP error occurs.
65+
*/
66+
public function fetch(): CallInstance {
67+
68+
$payload = $this->version->fetch('GET', $this->uri);
69+
70+
return new CallInstance($this->version, $payload, $this->solution['accountSid'], $this->solution['testInteger']);
71+
}
72+
73+
/**
74+
* Provide a friendly representation
75+
*
76+
* @return string Machine friendly representation
77+
*/
78+
public function __toString(): string {
79+
$context = [];
80+
foreach ($this->solution as $key => $value) {
81+
$context[] = "$key=$value";
82+
}
83+
return '[Twilio.Api.V2010.CallContext ' . \implode(' ', $context) . ']';
84+
}
85+
}

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323
use Twilio\Stream;
2424
use Twilio\Values;
2525
use Twilio\Version;
26+
use Twilio\InstanceContext;
27+
use Twilio\Deserialize;
28+
use Twilio\Serialize;
2629

2730

2831
/**

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

Lines changed: 30 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -14,55 +14,65 @@
1414
* Do not edit the class manually.
1515
*/
1616

17-
namespace Twilio\Rest\Api\V2010;
17+
namespace Twilio\Rest\Api\V2010\Account;
1818

1919
use Twilio\Exceptions\TwilioException;
2020
use Twilio\ListResource;
2121
use Twilio\Options;
2222
use Twilio\Stream;
2323
use Twilio\Values;
2424
use Twilio\Version;
25+
use Twilio\InstanceContext;
26+
use Twilio\Deserialize;
27+
use Twilio\Serialize;
2528

2629

30+
/**
31+
* @method \Twilio\Rest\Api\V2010\Account\Call\FeedbackCallSummaryContext feedbackCallSummary(string $sid)
32+
*/
33+
2734
class CallList extends ListResource {
2835
/**
2936
* Construct the CallList
3037
*
3138
* @param Version $version Version that contains the resource
32-
* @param string $accountSid
33-
* @param int $testInteger
39+
* @param string $accountSid
3440
*/
35-
public function __construct(Version $version, string $accountSid , int $testInteger ) {
41+
public function __construct(Version $version, string $accountSid ) {
3642
parent::__construct($version);
37-
$this->solution = ['account_sid' => $accountSid, 'test_integer' => $testInteger ];
43+
44+
// Path Solution
45+
$this->solution = ['account_sid' => $accountSid, ];
46+
3847
$this->uri = '/Accounts/' . \rawurlencode($accountSid) . '/Calls.json';
3948
}
4049

4150
/**
42-
* Create the CallInstance
43-
*
44-
* @param array|Options $options Optional Arguments
45-
* @return AccountInstance Created AccountInstance
46-
* @throws TwilioException When an HTTP error occurs.
47-
*/
48-
public function create(string $required_string_property ,string $test_method , array $options = []): CallInstance {
51+
* Create the CallInstance
52+
*
53+
* @param string $requiredStringProperty
54+
* @param string $testMethod The HTTP method that we should use to request the &#x60;TestArrayOfUri&#x60;.
55+
* @param array|Options $options Optional Arguments
56+
* @return CallInstance Created CallInstance
57+
* @throws TwilioException When an HTTP error occurs.
58+
*/
59+
public function create(string $requiredStringProperty, string $testMethod, array $options = []): CallInstance {
4960
$options = new Values($options);
5061

62+
5163
$data = Values::of([
52-
'RequiredStringProperty' => $required_string_property,
53-
'TestMethod' => $test_method,
54-
'AccountSid' => $options['AccountSid'],
55-
'TestArrayOfStrings' => Serialize::map($options['TestArrayOfStrings'], function($e) { return $e; }),
56-
'TestArrayOfUri' => Serialize::map($options['TestArrayOfUri'], function($e) { return $e; }),
64+
'RequiredStringProperty' => $requiredStringProperty,
65+
'TestMethod' => $testMethod,
66+
'TestArrayOfStrings' => Serialize::map($options['testArrayOfStrings'], function($e) { return $e; }),
67+
'TestArrayOfUri' => Serialize::map($options['testArrayOfUri'], function($e) { return $e; }),
5768
]);
5869

5970
$payload = $this->version->create('POST', $this->uri, [], $data);
6071

6172
return new CallInstance(
6273
$this->version,
63-
$payload,
64-
$this->solution['required_string_property'],
65-
$this->solution['test_method'],
74+
$payload
75+
, $this->solution['accountSid']
6676
);
6777
}
6878

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323
use Twilio\Stream;
2424
use Twilio\Values;
2525
use Twilio\Version;
26+
use Twilio\InstanceContext;
27+
use Twilio\Deserialize;
28+
use Twilio\Serialize;
2629

2730

2831
abstract class CallOptions {

0 commit comments

Comments
 (0)